Skip to content
Snippets Groups Projects
Commit 181964f7 authored by VishalAgarwal's avatar VishalAgarwal
Browse files

Periodic Backup

parent 5387474b
No related branches found
No related tags found
No related merge requests found
......@@ -26,9 +26,9 @@
*/
/**
* This class generates form components for processing Event Web Tracking
* This class generates form components for processing Contribution Web Tracking
*/
class CRM_WebTracking_Form_WebTracking extends CRM_Event_Form_ManageEvent {
class CRM_WebTracking_Form_ContributionPage_WebTracking extends CRM_Contribute_Form_ContributionPage {
/**
* Set variables up before form is built.
......@@ -43,12 +43,12 @@ class CRM_WebTracking_Form_WebTracking extends CRM_Event_Form_ManageEvent {
/**
* Set default values for the form
*
* @return void
* @return array
*/
public function setDefaultValues() {
$params['page_id']=$this->_id;
$params['page_category']="civicrm_event";
$params['page_category']="civicrm_contribution";
$defaults = array();
CRM_WebTracking_BAO_WebTracking::retrieve($params, $defaults);
......@@ -61,7 +61,6 @@ class CRM_WebTracking_Form_WebTracking extends CRM_Event_Form_ManageEvent {
* @return void
*/
public function buildQuickForm() {
// TODO:: Is this required?
$this->applyFilter('__ALL__', 'trim');
......@@ -73,9 +72,6 @@ class CRM_WebTracking_Form_WebTracking extends CRM_Event_Form_ManageEvent {
// Checkbox to ask whether or not to enable event tracking
$this->addElement('checkbox', 'ga_event_tracking', ts('Enable event tracking'));
// Checkbox to ask whether or not to track when the user visits the info page
$this->addElement('checkbox', 'track_info', ts('Track visit to info page'));
// Checkbox to ask whether or not to track when the user visits the registration page
$this->addElement('checkbox', 'track_register', ts('Track visit to registration page'));
......@@ -98,7 +94,7 @@ class CRM_WebTracking_Form_WebTracking extends CRM_Event_Form_ManageEvent {
// Text field to input the experiment key
$this->add('text', 'experiment_id', ts('Experiment key'));
$this->addFormRule(array('CRM_WebTracking_Form_WebTracking', 'formRule'));
$this->addFormRule(array('CRM_WebTracking_Form_ContributionPage_WebTracking', 'formRule'));
parent::buildQuickForm();
}
......@@ -118,7 +114,7 @@ class CRM_WebTracking_Form_WebTracking extends CRM_Event_Form_ManageEvent {
// Checking that UAID provided by the customer has the string 'UA-' as its prefix
$pos = strpos($values['tracking_id'],'UA-');
if ($pos===false || $pos!==0) {
$errors['tracking_id'] = ts('Please provide a valid tracking id');
$errors['tracking_id'] = ts('Please provide a valid tracking id');
}
}
......@@ -142,7 +138,7 @@ class CRM_WebTracking_Form_WebTracking extends CRM_Event_Form_ManageEvent {
$params = $this->controller->exportValues($this->_name);
$existParams['page_id'] = $this->_id;
$existParams['page_category'] = "civicrm_event";
$existParams['page_category'] = "civicrm_contribution";
$existingEnrty = array();
CRM_WebTracking_BAO_WebTracking::retrieve($existParams, $existingEnrty);
......@@ -152,13 +148,12 @@ class CRM_WebTracking_Form_WebTracking extends CRM_Event_Form_ManageEvent {
$params['id'] = $existingEnrty['id'];
}
$params['page_id'] = $this->_id;
$params['page_category']="civicrm_event";
$params['page_category']="civicrm_contribution";
$params['enable_tracking'] = CRM_Utils_Array::value('enable_tracking', $params, FALSE);
$params['tracking_id'] = CRM_Utils_Array::value('tracking_id', $params, NULL);
$params['ga_event_tracking'] = CRM_Utils_Array::value('ga_event_tracking', $params, FALSE);
$params['track_info'] = CRM_Utils_Array::value('track_info', $params, FALSE);
$params['track_register'] = CRM_Utils_Array::value('track_register', $params, FALSE);
$params['track_confirm_register'] = CRM_Utils_Array::value('track_confirm_register', $params, FALSE);
$params['track_thank_you'] = CRM_Utils_Array::value('track_thank_you', $params, FALSE);
......@@ -171,21 +166,9 @@ class CRM_WebTracking_Form_WebTracking extends CRM_Event_Form_ManageEvent {
// Updating the database with the new entry
$event = CRM_WebTracking_BAO_WebTracking::add($params);
if ($this->_action & CRM_Core_Action::ADD) {
$url = 'civicrm/event/manage/webtracking';
$urlParams = "action=update&reset=1&id={$event->id}";
// special case for 'Save and Done' consistency.
if ($this->controller->getButtonName('submit') == '_qf_EventInfo_upload_done') {
$url = 'civicrm/event/manage';
$urlParams = 'reset=1';
CRM_Core_Session::setStatus(ts("'%1' information has been saved.",
array(1 => $this->getTitle())
), ts('Saved'), 'success');
}
CRM_Utils_System::redirect(CRM_Utils_System::url($url, $urlParams));
}
$subPage = 'webtracking';
$nextPage = 'webtracking';
$subPageName = 'WebTracking';
parent::endPostProcess();
}
......@@ -196,7 +179,7 @@ class CRM_WebTracking_Form_WebTracking extends CRM_Event_Form_ManageEvent {
* @return string
*/
public function getTitle() {
return ts('Event Web Tracking Settings');
return ts('Contribution Web Tracking Settings');
}
}
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.6 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2015 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
* This class generates form components for processing Event Web Tracking
*/
class CRM_WebTracking_Form_Event extends CRM_Event_Form_ManageEvent {
/**
* Set variables up before form is built.
*
* @return void
*/
public function preProcess() {
CRM_Core_Resources::singleton()->addStyleFile('org.civicrm.webtracking', 'css/web-tracking-form.css');
parent::preProcess();
}
/**
* Set default values for the form
*
* @return void
*/
public function setDefaultValues() {
$params['page_id']=$this->_id;
$params['page_category']="civicrm_event";
$defaults = array();
CRM_WebTracking_BAO_WebTracking::retrieve($params, $defaults);
return $defaults;
}
/**
* Build the form object.
*
* @return void
*/
public function buildQuickForm() {
// TODO:: Is this required?
$this->applyFilter('__ALL__', 'trim');
// Checkbox to ask whether or not to enable web tracking
$this->addElement('checkbox', 'enable_tracking', ts('Enable web tracking'));
// Text field to input the tracking id
$this->add('text', 'tracking_id', ts('Tracking ID'));
// Checkbox to ask whether or not to enable event tracking
$this->addElement('checkbox', 'ga_event_tracking', ts('Enable event tracking'));
// Checkbox to ask whether or not to track when the user visits the info page
$this->addElement('checkbox', 'track_info', ts('Track visit to info page'));
// Checkbox to ask whether or not to track when the user visits the registration page
$this->addElement('checkbox', 'track_register', ts('Track visit to registration page'));
// Checkbox to ask whether or not to track when the user visits the confirmation page
$this->addElement('checkbox', 'track_confirm_register', ts('Track visit to confirmation page'));
// Checkbox to ask whether or not to track when the user visits the thank you page
$this->addElement('checkbox', 'track_thank_you', ts('Track visit to thank you page'));
// Checkbox to ask whether or not to track when the user changes default price option
$this->addElement('checkbox', 'track_price_change', ts('Track price change'));
// Checkbox to ask whether or not to enable ecommerce tracking
$this->addElement('checkbox', 'track_ecommerce', ts('Enable source tracking'));
// Checkbox to ask whether the page is the primary page of the experiment
$this->addElement('checkbox', 'is_experiment', ts('Primary page of experiment'));
// Text field to input the experiment key
$this->add('text', 'experiment_id', ts('Experiment key'));
$this->addFormRule(array('CRM_WebTracking_Form_Event', 'formRule'));
parent::buildQuickForm();
}
/**
* Global validation rules for the form.
*
* @param array $values
*
* @return array
* list of errors to be posted back to the form
*/
public static function formRule($values) {
$errors = array();
if (isset($values['enable_tracking']) && $values['enable_tracking'] == 1) {
// Checking that UAID provided by the customer has the string 'UA-' as its prefix
$pos = strpos($values['tracking_id'],'UA-');
if ($pos===false || $pos!==0) {
$errors['tracking_id'] = ts('Please provide a valid tracking id');
}
}
if (isset($values['is_experiment']) && $values['is_experiment'] == 1) {
if ($values['experiment_id'] == '') {
$errors['experiment_id'] = ts('Please provide a valid experiment key');
}
}
return $errors;
}
/**
* Process the form submission.
*
* @return void
*/
public function postProcess() {
// TODO:: is this required?
$params = $this->controller->exportValues($this->_name);
$existParams['page_id'] = $this->_id;
$existParams['page_category'] = "civicrm_event";
$existingEnrty = array();
CRM_WebTracking_BAO_WebTracking::retrieve($existParams, $existingEnrty);
// Setting up the params array with the values obtained from the form
if (!empty($existingEnrty)) {
$params['id'] = $existingEnrty['id'];
}
$params['page_id'] = $this->_id;
$params['page_category']="civicrm_event";
$params['enable_tracking'] = CRM_Utils_Array::value('enable_tracking', $params, FALSE);
$params['tracking_id'] = CRM_Utils_Array::value('tracking_id', $params, NULL);
$params['ga_event_tracking'] = CRM_Utils_Array::value('ga_event_tracking', $params, FALSE);
$params['track_info'] = CRM_Utils_Array::value('track_info', $params, FALSE);
$params['track_register'] = CRM_Utils_Array::value('track_register', $params, FALSE);
$params['track_confirm_register'] = CRM_Utils_Array::value('track_confirm_register', $params, FALSE);
$params['track_thank_you'] = CRM_Utils_Array::value('track_thank_you', $params, FALSE);
$params['track_price_change'] = CRM_Utils_Array::value('track_price_change', $params, FALSE);
$params['track_ecommerce'] = CRM_Utils_Array::value('track_ecommerce', $params, FALSE);
$params['is_experiment'] = CRM_Utils_Array::value('is_experiment', $params, FALSE);
$params['experiment_id'] = CRM_Utils_Array::value('experiment_id', $params, NULL);
// Updating the database with the new entry
$event = CRM_WebTracking_BAO_WebTracking::add($params);
parent::endPostProcess();
}
/**
* Return a descriptive name for the page, used in wizard header
*
* @return string
*/
public function getTitle() {
return ts('Event Web Tracking Settings');
}
}
{*
+--------------------------------------------------------------------+
| CiviCRM version 4.6 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2015 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*}
<div class="crm-block crm-form-block crm-event-manage-webtracking-form-block">
<div class="crm-submit-buttons">
{include file="CRM/common/formButtons.tpl" location="top"}
</div>
<table class="form-table-webtracking">
<tr class="crm-event-manage-webtracking-form-block-enable_tracking" id="enable-tracking">
<td>&nbsp;</td>
<td>{$form.enable_tracking.html} {$form.enable_tracking.label}</td>
</tr>
<table class="form-table-webtracking" id="webtracking-params">
<tr class="crm-event-manage-webtracking-form-block-tracking_id">
<td>{$form.tracking_id.label} {help id="tracking-id"}</td>
<td>{$form.tracking_id.html} </br></td>
</tr>
<tr class="crm-event-manage-eventinfo-form-block-ga_event_tracking">
<td>&nbsp;</td>
<td>{$form.ga_event_tracking.html} {$form.ga_event_tracking.label} {help id="ga-event-tracking"}</td>
</tr>
<tbody id="eventtracking-params">
<tr class="crm-event-manage-eventinfo-form-block-track_register">
<td>&nbsp;</td>
<td>{$form.track_register.html} {$form.track_register.label}</td>
</tr>
<tr class="crm-event-manage-eventinfo-form-block-track_confirm_register">
<td>&nbsp;</td>
<td>{$form.track_confirm_register.html} {$form.track_confirm_register.label}</td>
</tr>
<tr class="crm-event-manage-eventinfo-form-block-track_thank_you">
<td>&nbsp;</td>
<td>{$form.track_thank_you.html} {$form.track_thank_you.label}</td>
</tr>
<tr class="crm-event-manage-eventinfo-form-block-track_price_change">
<td>&nbsp;</td>
<td>{$form.track_price_change.html} {$form.track_price_change.label}</td>
</tr>
</tbody>
<tr class="crm-event-manage-eventinfo-form-block-track_ecommerce">
<td>&nbsp;</td>
<td>{$form.track_ecommerce.html} {$form.track_ecommerce.label} {help id="track-ecommerce"}</td>
</tr>
<tr class="crm-event-manage-eventinfo-form-block-is_experiment">
<td>&nbsp;</td>
<td>{$form.is_experiment.html} {$form.is_experiment.label} {help id="is-experiment"}</td>
</tr>
<tr class="crm-event-manage-eventinfo-form-block-experiment_id" id="experiment-id">
<td>{$form.experiment_id.label} {help id="experiment-id"}</td>
<td>{$form.experiment_id.html} </br></td>
</tr>
</table>
</table>
<div class="crm-submit-buttons">
{include file="CRM/common/formButtons.tpl" location="bottom"}
</div>
</div>
{literal}
<script type="text/javascript">
CRM.$(function($) {
if (!$('#is_experiment').is(':checked')) {
$('#experiment-id').hide();
}
if (!$('#ga_event_tracking').is(':checked')) {
$('#eventtracking-params').hide();
}
if (!$('#enable_tracking').is(':checked')) {
$('#webtracking-params').hide();
}
$('#is_experiment').on('click', function() {
$('#experiment-id').toggle();
});
$('#ga_event_tracking').on('click', function() {
$('#eventtracking-params').toggle();
});
$('#enable_tracking').on('click', function() {
$('#webtracking-params').toggle();
});
});
</script>
{/literal}
{*
+--------------------------------------------------------------------+
| CiviCRM version 4.6 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2015 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*}
{htxt id="tracking-id-title"}
{ts}Tracking ID{/ts}
{/htxt}
{htxt id="tracking-id"}
<p>{ts}This is an unique id generated by google analytics. To get the tracking id for your event/contribution page you will have to sign up on http://www.google.co.in/analytics{/ts}</p>
<p>{ts}After signing up on google analytics follow this guide to get your tracking id https://support.google.com/analytics/answer/1042508?hl=en{/ts}</p>
{/htxt}
{htxt id="ga-event-tracking-title"}
{ts}Google Analytics Event Tracking{/ts}
{/htxt}
{htxt id="ga-event-tracking"}
<p>{ts}This feature records peculiar things which visitors do when interacting with the event/contribution page.{/ts}</p>
<p>{ts}It records when visitors choose to change the price option from the deafult amount. It records some metrics like the number of times the info page was viewed, the registration page was viewed, the confirmation page was viewed and the thank you page was viewed.{/ts}</p>
{/htxt}
{htxt id="track-ecommerce-title"}
{ts}Source Tracking{/ts}
{/htxt}
{htxt id="track-ecommerce"}
<p>{ts}This feature enables one to determing the amount of money which is raised through referrals. For example, it enables one to determine the amount of revenue which was generated due to people tweeting about the event, due to people liking the page on Facebook, etc.{/ts}</p>
{/htxt}
{htxt id="is-experiment-title"}
{ts}Experiment{/ts}
{/htxt}
{htxt id="is-experiment"}
<p>{ts}This feature enables one to do A/B testing on variants of event/contribution pages.{/ts}</p>
<p>{ts}To use this feature an experiment needs to be setup on google analytics. Follow the steps in this guide to setup an experiment https://support.google.com/analytics/answer/1745216?hl=en{/ts}</p>
<p>{ts}Note: This checkbox needs to be checked only for the primary variant of your event/contribution page. For the other variants of your event/contribution page the 'Enable web tracking' checkbox should be checked. The 'Tracking ID' will be same for ALL the variants (both the primary as well as the other experimental variants).{/ts}</p>
{/htxt}
{htxt id="experiment-id-title"}
{ts}Experiment Key{/ts}
{/htxt}
{htxt id="experiment-id"}
<p>{ts}This is an unique id generated by google analytics for your experiment.{/ts}</p>
{/htxt}
\ No newline at end of file
......@@ -156,8 +156,7 @@ function webtracking_civicrm_tabset($tabsetName, &$tabs, $context) {
//Insert this tab in the end
$tabs = array_merge($tabs,$tab);
}
if ($tabsetName == 'civicrm/event/manage/rows') {
else if ($tabsetName == 'civicrm/event/manage/rows') {
if (!empty($context)) {
$eventID = $context['event_id'];
$trackingParams = array('page_id' => $eventID, 'page_category' => "civicrm_event");
......@@ -165,6 +164,42 @@ function webtracking_civicrm_tabset($tabsetName, &$tabs, $context) {
$tabs[$eventID]['enable_tracking'] = $trackingValues['enable_tracking'];
}
}
else if ($tabsetName == 'civicrm/admin/contribute') {
if (!empty($context)) {
$contribPageId = $context['contrib_page_id'];
$trackingParams = array('page_id' => $contribPageId, 'page_category' => "civicrm_contribution");
CRM_WebTracking_BAO_WebTracking::retrieve($trackingParams,$trackingValues);
$url = CRM_Utils_System::url( 'civicrm/admin/contribute/webtracking',
"reset=1&snippet=5&force=1&id=$contribPageId&action=update&component=contribute" );
// Add a new WebTracking tab along with url
$tab['webtracking'] = array(
'title' => ts('Web Tracking'),
'link' => $url,
'valid' => $trackingValues['enable_tracking'],
'active' => 1,
'current' => false,
);
}
else {
$tab['webtracking'] = array(
'title' => ts('Web Tracking'),
'url' => 'civicrm/admin/contribute/webtracking',
'field' => 'enable_tracking',
);
}
//Insert this tab in the end
$tabs = array_merge($tabs,$tab);
}
else if ($tabsetName == 'civicrm/admin/contribute/rows') {
if (!empty($context)) {
$contribPageId = $context['contrib_page_id'];
$trackingParams = array('page_id' => $contribPageId, 'page_category' => "civicrm_contribution");
CRM_WebTracking_BAO_WebTracking::retrieve($trackingParams,$trackingValues);
$tabs[$contribPageId]['enable_tracking'] = $trackingValues['enable_tracking'];
}
}
}
/**
......@@ -222,10 +257,17 @@ function webtracking_civicrm_pageRun(&$page) {
*/
function webtracking_civicrm_buildForm($formName, &$form) {
$contribFormNames = array('CRM_Contribute_Form_Contribution_Main');
$eventFormNames = array('CRM_Event_Form_Registration_Register', 'CRM_Event_Form_Registration_ThankYou', 'CRM_Event_Form_Registration_Confirm');
if (in_array($formName, $eventFormNames)) {
if (in_array($formName, $eventFormNames) || in_array($formName, $contribFormNames)) {
if (in_array($formName, $eventFormNames)) {
$trackingParams = array('page_id' => $form->_eventId, 'page_category' => "civicrm_event");
}
else {
$trackingParams = array('page_id' => $form->_id, 'page_category' => "civicrm_contribution");
}
$trackingParams = array('page_id' => $form->_eventId, 'page_category' => "civicrm_event");
CRM_WebTracking_BAO_WebTracking::retrieve($trackingParams,$trackingValues);
if ($trackingValues['enable_tracking'] == 1) {
......@@ -240,7 +282,7 @@ function webtracking_civicrm_buildForm($formName, &$form) {
return;
}
if ($formName == 'CRM_Event_Form_Registration_Register') {
if ($formName == 'CRM_Event_Form_Registration_Register' || $formName == 'CRM_Contribute_Form_Contribution_Main') {
if ($trackingValues['track_register'] == 1) {
CRM_Core_Resources::singleton()->addScript('trackViewRegistration();');
}
......
......@@ -2,7 +2,13 @@
<menu>
<item>
<path>civicrm/event/manage/webtracking</path>
<page_callback>CRM_WebTracking_Form_WebTracking</page_callback>
<page_callback>CRM_WebTracking_Form_Event</page_callback>
<title>Web Tracking</title>
<access_arguments>access CiviCRM</access_arguments>
</item>
<item>
<path>civicrm/admin/contribute/webtracking</path>
<page_callback>CRM_WebTracking_Form_ContributionPage_WebTracking</page_callback>
<title>Web Tracking</title>
<access_arguments>access CiviCRM</access_arguments>
</item>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment