Commit e33f56ae authored by neochief's avatar neochief Committed by hass
Browse files

Issue #1833578: Add support Enhanced Link Attribution

parent b54e232b
......@@ -201,6 +201,12 @@ function googleanalytics_admin_settings_form($form_state) {
'#description' => t('A file extension list separated by the | character that will be tracked as download when clicked. Regular expressions are supported. For example: !extensions', array('!extensions' => GOOGLEANALYTICS_TRACKFILES_EXTENSIONS)),
'#maxlength' => 255,
);
$form['tracking']['linktracking']['googleanalytics_tracklinkid'] = array(
'#type' => 'checkbox',
'#title' => t('Enable enhanced link attribution'),
'#default_value' => variable_get('googleanalytics_tracklinkid', 0),
'#description' => t('Enhancements: separate click tracking for multiple links on a page with the same destination, better tracking for search buttons, and tracking for javascript links/buttons. To use this you must enable <a href="@url">enhanced link attribution</a> for this site on your Google Analytics account.', array('@url' => url('http://support.google.com/analytics/bin/answer.py', array('query' => array('answer' => '2558867'))))),
);
// Message specific configurations.
$form['tracking']['messagetracking'] = array(
......
......@@ -41,6 +41,7 @@ function googleanalytics_uninstall() {
variable_del('googleanalytics_tracker_anonymizeip');
variable_del('googleanalytics_trackfiles');
variable_del('googleanalytics_trackfiles_extensions');
variable_del('googleanalytics_tracklinkid');
variable_del('googleanalytics_trackmailto');
variable_del('googleanalytics_trackmessages');
variable_del('googleanalytics_trackoutbound');
......
......@@ -259,6 +259,12 @@ function googleanalytics_page_alter(&$page) {
$script .= 'ga("set", "anonymizeIp", 1);';
}
// Add enhanced link attribution after 'create', but before 'pageview' send.
// @see https://support.google.com/analytics/answer/2558867
if (variable_get('googleanalytics_tracklinkid', 0)) {
$script .= 'ga("require", "linkid", "linkid.js");';
}
// Prepare Adsense tracking.
$googleanalytics_adsense_script = 'window.google_analytics_uacct = ' . drupal_json_encode($id) . ';';
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment