updated mailgun, mailsystem, honeypot, googleanalitycs, features, content_taxonomy
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
|
||||
Module: Google Analytics
|
||||
Author: Alexander Hass <http://drupal.org/user/85918>
|
||||
Author: Alexander Hass <https://drupal.org/user/85918>
|
||||
|
||||
|
||||
Description
|
||||
@@ -53,15 +53,15 @@ user with 'Administer Google Analytics' permission.
|
||||
Like the blocks visibility settings in Drupal core, there is a choice for
|
||||
"Add if the following PHP code returns TRUE." Sample PHP snippets that can be
|
||||
used in this textarea can be found on the handbook page "Overview-approach to
|
||||
block visibility" at http://drupal.org/node/64135.
|
||||
block visibility" at https://drupal.org/node/64135.
|
||||
|
||||
Custom dimensions and metrics
|
||||
=============================
|
||||
One example for custom dimensions tracking is the "User roles" tracking.
|
||||
|
||||
1. In the Google Analytics Management Interface (http://www.google.com/analytics/)
|
||||
you need to setup Dimension #1 with name e.g. "User roles". This step is
|
||||
required. Do not miss it, please.
|
||||
1. In the Google Analytics (https://marketingplatform.google.com/about/analytics/)
|
||||
Management Interface you need to setup Dimension #1 with name
|
||||
e.g. "User roles". This step is required. Do not miss it, please.
|
||||
|
||||
2. Enter the below configuration data into the Drupal custom dimensions settings
|
||||
form under admin/config/system/googleanalytics. You can also choose another
|
||||
@@ -77,7 +77,7 @@ Advanced Settings
|
||||
=================
|
||||
You can include additional JavaScript snippets in the custom javascript
|
||||
code textarea. These can be found on the official Google Analytics pages
|
||||
and a few examples at http://drupal.org/node/248699. Support is not
|
||||
and a few examples at https://drupal.org/node/248699. Support is not
|
||||
provided for any customisations you include.
|
||||
|
||||
To speed up page loading you may also cache the Google Analytics "analytics.js"
|
||||
@@ -97,7 +97,7 @@ Body:
|
||||
<li><a href="mailto:foo@example.com">Mailto</a></li>
|
||||
<li><a href="/files/test.txt">Download file</a></li>
|
||||
<li><a class="colorbox" href="#">Open colorbox</a></li>
|
||||
<li><a href="http://example.com/">External link</a></li>
|
||||
<li><a href="https://example.com/">External link</a></li>
|
||||
<li><a href="/go/test">Go link</a></li>
|
||||
</ul>
|
||||
|
||||
|
@@ -18,10 +18,17 @@ function googleanalytics_admin_settings_form($form_state) {
|
||||
'#title' => t('Web Property ID'),
|
||||
'#type' => 'textfield',
|
||||
'#default_value' => variable_get('googleanalytics_account', 'UA-'),
|
||||
'#size' => 15,
|
||||
'#size' => 20,
|
||||
'#maxlength' => 20,
|
||||
'#required' => TRUE,
|
||||
'#description' => t('This ID is unique to each site you want to track separately, and is in the form of UA-xxxxxxx-yy. To get a Web Property ID, <a href="@analytics">register your site with Google Analytics</a>, or if you already have registered your site, go to your Google Analytics Settings page to see the ID next to every site profile. <a href="@webpropertyid">Find more information in the documentation</a>.', array('@analytics' => 'http://www.google.com/analytics/', '@webpropertyid' => url('https://developers.google.com/analytics/resources/concepts/gaConceptsAccounts', array('fragment' => 'webProperty')))),
|
||||
'#description' => t('This ID is unique to each site you want to track separately, and is in the form of UA-xxxxxxx-yy. To get a Web Property ID, <a href="@analytics">register your site with Google Analytics</a>, or if you already have registered your site, go to your Google Analytics Settings page to see the ID next to every site profile. <a href="@webpropertyid">Find more information in the documentation</a>.', array('@analytics' => 'https://marketingplatform.google.com/about/analytics/', '@webpropertyid' => url('https://developers.google.com/analytics/resources/concepts/gaConceptsAccounts', array('fragment' => 'webProperty')))),
|
||||
);
|
||||
|
||||
$form['account']['googleanalytics_premium'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Premium account'),
|
||||
'#description' => t('If you are a Google Analytics Premium customer, you can use up to 200 instead of 20 custom dimensions and metrics.'),
|
||||
'#default_value' => variable_get('googleanalytics_premium', FALSE),
|
||||
);
|
||||
|
||||
// Visibility settings.
|
||||
@@ -169,7 +176,7 @@ function googleanalytics_admin_settings_form($form_state) {
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Users'),
|
||||
);
|
||||
$t_permission = array('%permission' => t('opt-in or out of tracking'));
|
||||
$t_permission = array('%permission' => t('Opt-in or out of tracking'));
|
||||
$form['tracking']['user_vis_settings']['googleanalytics_custom'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Allow users to customize tracking on their account page'),
|
||||
@@ -309,7 +316,7 @@ function googleanalytics_admin_settings_form($form_state) {
|
||||
$form['tracking']['privacy']['googleanalytics_privacy_donottrack'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Universal web tracking opt-out'),
|
||||
'#description' => t('If enabled and your server receives the <a href="@donottrack">Do-Not-Track</a> header from the client browser, the Google Analytics module will not embed any tracking code into your site. Compliance with Do Not Track could be purely voluntary, enforced by industry self-regulation, or mandated by state or federal law. Please accept your visitors privacy. If they have opt-out from tracking and advertising, you should accept their personal decision. This feature is currently limited to logged in users and disabled page caching.', array('@donottrack' => 'http://donottrack.us/')),
|
||||
'#description' => t('If enabled and your server receives the <a href="@donottrack">Do-Not-Track</a> header from the client browser, the Google Analytics module will not embed any tracking code into your site. Compliance with Do Not Track could be purely voluntary, enforced by industry self-regulation, or mandated by state or federal law. Please accept your visitors privacy. If they have opt-out from tracking and advertising, you should accept their personal decision. This feature is currently limited to logged in users and disabled page caching.', array('@donottrack' => 'https://www.eff.org/issues/do-not-track')),
|
||||
'#default_value' => variable_get('googleanalytics_privacy_donottrack', 1),
|
||||
);
|
||||
|
||||
@@ -326,8 +333,10 @@ function googleanalytics_admin_settings_form($form_state) {
|
||||
|
||||
$googleanalytics_custom_dimension = variable_get('googleanalytics_custom_dimension', array());
|
||||
|
||||
// Google Analytics supports up to 20 custom dimensions.
|
||||
for ($i = 1; $i <= 20; $i++) {
|
||||
// Standard Google Analytics accounts support up to 20 custom dimensions,
|
||||
// premium accounts support up to 200 custom dimensions.
|
||||
$limit = (variable_get('googleanalytics_premium', FALSE)) ? 200 : 20;
|
||||
for ($i = 1; $i <= $limit; $i++) {
|
||||
$form['googleanalytics_custom_dimension']['indexes'][$i]['index'] = array(
|
||||
'#default_value' => $i,
|
||||
'#description' => t('Index number'),
|
||||
@@ -354,7 +363,7 @@ function googleanalytics_admin_settings_form($form_state) {
|
||||
|
||||
$form['googleanalytics_custom_dimension']['googleanalytics_description'] = array(
|
||||
'#type' => 'item',
|
||||
'#description' => t('You can supplement Google Analytics\' basic IP address tracking of visitors by segmenting users based on custom dimensions. Section 7 of the <a href="@ga_tos">Google Analytics terms of service</a> requires that You will not (and will not allow any third party to) use the Service to track, collect or upload any data that personally identifies an individual (such as a name, userid, email address or billing information), or other data which can be reasonably linked to such information by Google. You will have and abide by an appropriate Privacy Policy and will comply with all applicable laws and regulations relating to the collection of information from Visitors. You must post a Privacy Policy and that Privacy Policy must provide notice of Your use of cookies that are used to collect traffic data, and You must not circumvent any privacy features (e.g., an opt-out) that are part of the Service.', array('@ga_tos' => 'http://www.google.com/analytics/terms/gb.html')),
|
||||
'#description' => t('You can supplement Google Analytics\' basic IP address tracking of visitors by segmenting users based on custom dimensions. Section 7 of the <a href="@ga_tos">Google Analytics terms of service</a> requires that You will not (and will not allow any third party to) use the Service to track, collect or upload any data that personally identifies an individual (such as a name, userid, email address or billing information), or other data which can be reasonably linked to such information by Google. You will have and abide by an appropriate Privacy Policy and will comply with all applicable laws and regulations relating to the collection of information from Visitors. You must post a Privacy Policy and that Privacy Policy must provide notice of Your use of cookies that are used to collect traffic data, and You must not circumvent any privacy features (e.g., an opt-out) that are part of the Service.', array('@ga_tos' => 'https://www.google.com/analytics/terms/gb.html')),
|
||||
);
|
||||
if (module_exists('token')) {
|
||||
$form['googleanalytics_custom_dimension']['googleanalytics_token_tree'] = array(
|
||||
@@ -377,8 +386,9 @@ function googleanalytics_admin_settings_form($form_state) {
|
||||
|
||||
$googleanalytics_custom_metric = variable_get('googleanalytics_custom_metric', array());
|
||||
|
||||
// Google Analytics supports up to 20 custom metrics.
|
||||
for ($i = 1; $i <= 20; $i++) {
|
||||
// Standard Google Analytics accounts support up to 20 custom metrics,
|
||||
// premium accounts support up to 200 custom metrics.
|
||||
for ($i = 1; $i <= $limit; $i++) {
|
||||
$form['googleanalytics_custom_metric']['indexes'][$i]['index'] = array(
|
||||
'#default_value' => $i,
|
||||
'#description' => t('Index number'),
|
||||
@@ -405,7 +415,7 @@ function googleanalytics_admin_settings_form($form_state) {
|
||||
|
||||
$form['googleanalytics_custom_metric']['googleanalytics_description'] = array(
|
||||
'#type' => 'item',
|
||||
'#description' => t('You can supplement Google Analytics\' basic IP address tracking of visitors by segmenting users based on custom metrics. Section 7 of the <a href="@ga_tos">Google Analytics terms of service</a> requires that You will not (and will not allow any third party to) use the Service to track, collect or upload any data that personally identifies an individual (such as a name, userid, email address or billing information), or other data which can be reasonably linked to such information by Google. You will have and abide by an appropriate Privacy Policy and will comply with all applicable laws and regulations relating to the collection of information from Visitors. You must post a Privacy Policy and that Privacy Policy must provide notice of Your use of cookies that are used to collect traffic data, and You must not circumvent any privacy features (e.g., an opt-out) that are part of the Service.', array('@ga_tos' => 'http://www.google.com/analytics/terms/gb.html')),
|
||||
'#description' => t('You can supplement Google Analytics\' basic IP address tracking of visitors by segmenting users based on custom metrics. Section 7 of the <a href="@ga_tos">Google Analytics terms of service</a> requires that You will not (and will not allow any third party to) use the Service to track, collect or upload any data that personally identifies an individual (such as a name, userid, email address or billing information), or other data which can be reasonably linked to such information by Google. You will have and abide by an appropriate Privacy Policy and will comply with all applicable laws and regulations relating to the collection of information from Visitors. You must post a Privacy Policy and that Privacy Policy must provide notice of Your use of cookies that are used to collect traffic data, and You must not circumvent any privacy features (e.g., an opt-out) that are part of the Service.', array('@ga_tos' => 'https://www.google.com/analytics/terms/gb.html')),
|
||||
);
|
||||
if (module_exists('token')) {
|
||||
$form['googleanalytics_custom_metric']['googleanalytics_token_tree'] = array(
|
||||
@@ -447,7 +457,7 @@ function googleanalytics_admin_settings_form($form_state) {
|
||||
'#title' => t('Custom JavaScript code'),
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => TRUE,
|
||||
'#description' => t('You can add custom Google Analytics <a href="@snippets">code snippets</a> here. These will be added every time tracking is in effect. Before you add your custom code, you should read the <a href="@ga_concepts_overview">Google Analytics Tracking Code - Functional Overview</a> and the <a href="@ga_js_api">Google Analytics Tracking API</a> documentation. <strong>Do not include the <script> tags</strong>, and always end your code with a semicolon (;).', array('@snippets' => 'http://drupal.org/node/248699', '@ga_concepts_overview' => 'https://developers.google.com/analytics/resources/concepts/gaConceptsTrackingOverview', '@ga_js_api' => 'https://developers.google.com/analytics/devguides/collection/analyticsjs/method-reference')),
|
||||
'#description' => t('You can add custom Google Analytics <a href="@snippets">code snippets</a> here. These will be added every time tracking is in effect. Before you add your custom code, you should read the <a href="@ga_concepts_overview">Google Analytics Tracking Code - Functional Overview</a> and the <a href="@ga_js_api">Google Analytics Tracking API</a> documentation. <strong>Do not include the <script> tags</strong>, and always end your code with a semicolon (;).', array('@snippets' => 'https://drupal.org/node/248699', '@ga_concepts_overview' => 'https://developers.google.com/analytics/resources/concepts/gaConceptsTrackingOverview', '@ga_js_api' => 'https://developers.google.com/analytics/devguides/collection/analyticsjs/method-reference')),
|
||||
);
|
||||
$form['advanced']['codesnippet']['googleanalytics_codesnippet_create'] = array(
|
||||
'#type' => 'textarea',
|
||||
@@ -785,16 +795,18 @@ function _googleanalytics_validate_create_field_name($name) {
|
||||
// List of supported field names:
|
||||
// https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#create
|
||||
$create_only_fields = array(
|
||||
'clientId',
|
||||
'userId',
|
||||
'sampleRate',
|
||||
'siteSpeedSampleRate',
|
||||
'alwaysSendReferrer',
|
||||
'allowAnchor',
|
||||
'alwaysSendReferrer',
|
||||
'clientId',
|
||||
'cookieName',
|
||||
'cookieDomain',
|
||||
'cookieExpires',
|
||||
'legacyCookieDomain',
|
||||
'legacyHistoryImport',
|
||||
'sampleRate',
|
||||
'siteSpeedSampleRate',
|
||||
'storage',
|
||||
'useAmpClientId',
|
||||
);
|
||||
|
||||
if ($name == 'name') {
|
||||
@@ -803,6 +815,9 @@ function _googleanalytics_validate_create_field_name($name) {
|
||||
if ($name == 'allowLinker') {
|
||||
return t('Create only field name %name is a disallowed field name. Please select <em>Multiple top-level domains</em> under <em>What are you tracking</em> to enable cross domain tracking.', array('%name' => $name));
|
||||
}
|
||||
if ($name == 'userId') {
|
||||
return t('Create only field name %name is a disallowed field name. Please enable <em>Track User ID</em> under <em>Tracking scope > Users</em>.', array('%name' => $name));
|
||||
}
|
||||
if (!in_array($name, $create_only_fields)) {
|
||||
return t('Create only field name %name is an unknown field name. Field names are case sensitive. Please see <a href="@url">create only fields</a> documentation for supported field names.', array('%name' => $name, '@url' => 'https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#create'));
|
||||
}
|
||||
|
@@ -122,7 +122,7 @@ $(document).ready(function() {
|
||||
Drupal.googleanalytics.isCrossDomain = function (hostname, crossDomains) {
|
||||
/**
|
||||
* jQuery < 1.6.3 bug: $.inArray crushes IE6 and Chrome if second argument is
|
||||
* `null` or `undefined`, http://bugs.jquery.com/ticket/10076,
|
||||
* `null` or `undefined`, https://bugs.jquery.com/ticket/10076,
|
||||
* https://github.com/jquery/jquery/commit/a839af034db2bd934e4d4fa6758a3fed8de74174
|
||||
*
|
||||
* @todo: Remove/Refactor in D8
|
||||
@@ -181,8 +181,8 @@ Drupal.googleanalytics.isInternalSpecial = function (url) {
|
||||
* Extract the relative internal URL from an absolute internal URL.
|
||||
*
|
||||
* Examples:
|
||||
* - http://mydomain.com/node/1 -> /node/1
|
||||
* - http://example.com/foo/bar -> http://example.com/foo/bar
|
||||
* - https://mydomain.com/node/1 -> /node/1
|
||||
* - https://example.com/foo/bar -> https://example.com/foo/bar
|
||||
*
|
||||
* @param string url
|
||||
* The web url to check.
|
||||
|
@@ -5,9 +5,8 @@ package = Statistics
|
||||
configure = admin/config/system/googleanalytics
|
||||
files[] = googleanalytics.test
|
||||
test_dependencies[] = token
|
||||
; Information added by Drupal.org packaging script on 2016-08-09
|
||||
version = "7.x-2.3"
|
||||
; Information added by Drupal.org packaging script on 2019-01-31
|
||||
version = "7.x-2.6"
|
||||
core = "7.x"
|
||||
project = "google_analytics"
|
||||
datestamp = "1470779953"
|
||||
|
||||
datestamp = "1548968597"
|
||||
|
@@ -10,6 +10,7 @@
|
||||
*/
|
||||
function googleanalytics_uninstall() {
|
||||
variable_del('googleanalytics_account');
|
||||
variable_del('googleanalytics_premium');
|
||||
variable_del('googleanalytics_cache');
|
||||
variable_del('googleanalytics_codesnippet_create');
|
||||
variable_del('googleanalytics_codesnippet_before');
|
||||
@@ -41,7 +42,7 @@ function googleanalytics_uninstall() {
|
||||
variable_del('googleanalytics_visibility_roles');
|
||||
variable_del('googleanalytics_privacy_donottrack');
|
||||
|
||||
// Remove backup variables if exist. Remove this code in D8.
|
||||
// Remove backup variables if they exist. Remove this code in D8.
|
||||
variable_del('googleanalytics_codesnippet_after_backup_7200');
|
||||
variable_del('googleanalytics_codesnippet_before_backup_7200');
|
||||
}
|
||||
@@ -88,7 +89,8 @@ function googleanalytics_requirements($phase) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Upgrade old extension variable to new and use old name as enabled/disabled flag.
|
||||
* Upgrade old extension variable to new and use old name as enabled/disabled
|
||||
* flag.
|
||||
*/
|
||||
function googleanalytics_update_6000() {
|
||||
variable_set('googleanalytics_trackfiles_extensions', variable_get('googleanalytics_trackfiles', '7z|aac|avi|csv|doc|exe|flv|gif|gz|jpe?g|js|mp(3|4|e?g)|mov|pdf|phps|png|ppt|rar|sit|tar|torrent|txt|wma|wmv|xls|xml|zip'));
|
||||
@@ -101,7 +103,8 @@ function googleanalytics_update_6000() {
|
||||
function googleanalytics_update_6001() {
|
||||
variable_set('googleanalytics_visibility', 0);
|
||||
|
||||
// Remove tracking from all administrative pages, see http://drupal.org/node/34970.
|
||||
// Remove tracking from all administrative pages, see:
|
||||
// https://drupal.org/node/34970.
|
||||
$pages = array(
|
||||
'admin*',
|
||||
'user*',
|
||||
@@ -114,11 +117,12 @@ function googleanalytics_update_6001() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Upgrade role settings and per user tracking settings
|
||||
* of "User 1" and remove outdated tracking variables.
|
||||
* Upgrade role settings and per user tracking settings of "User 1" and remove
|
||||
* outdated tracking variables.
|
||||
*/
|
||||
function googleanalytics_update_6002() {
|
||||
// Upgrade enabled/disabled roles to new logic (correct for upgrades from 5.x-1.4 and 6.x-1.0).
|
||||
// Upgrade enabled/disabled roles to new logic (correct for upgrades from
|
||||
// 5.x-1.4 and 6.x-1.0).
|
||||
$roles = array();
|
||||
$messages = array();
|
||||
foreach (user_roles() as $rid => $name) {
|
||||
@@ -137,7 +141,7 @@ function googleanalytics_update_6002() {
|
||||
if (!$track_user1 = variable_get('googleanalytics_track__user1', 1)) {
|
||||
variable_set('googleanalytics_custom', 1);
|
||||
|
||||
// Load user 1 object, set appropriate value and save new user settings back.
|
||||
// Load user 1 object, set appropriate value and save new user settings.
|
||||
$account = user_load(1);
|
||||
$account = user_save($account, array('data' => array('googleanalytics' => array('custom' => 0))), 'account');
|
||||
$messages[] = t('Disabled user specific page tracking for site administrator.');
|
||||
@@ -152,11 +156,11 @@ function googleanalytics_update_6002() {
|
||||
}
|
||||
|
||||
/**
|
||||
* #262468: Clear menu cache to solve stale menu data in 5.x-1.5 and 6.x-1.1
|
||||
* #262468: Clear menu cache to solve stale menu data in 5.x-1.5 and 6.x-1.1.
|
||||
*/
|
||||
function googleanalytics_update_6003() {
|
||||
menu_rebuild();
|
||||
return t('Menu has been rebuild.');
|
||||
return t('Menu has been rebuilt.');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -231,8 +235,9 @@ function googleanalytics_update_6006() {
|
||||
/**
|
||||
* Remove "User identifier" and "User name" from segmentation fields.
|
||||
*
|
||||
* This is a data protection and privacy law change. For more information see Google Analytics
|
||||
* terms of use section 8.1 (http://www.google.com/analytics/en-GB/tos.html).
|
||||
* This is a data protection and privacy law change. For more information see
|
||||
* Google Analytics terms of use section 8.1:
|
||||
* https://www.google.com/analytics/en-GB/tos.html
|
||||
*/
|
||||
function googleanalytics_update_6007() {
|
||||
$profile_fields = variable_get('googleanalytics_segmentation', array());
|
||||
@@ -293,15 +298,15 @@ function googleanalytics_update_6300() {
|
||||
$messages[] = t('Upgraded custom "before" code snippet.');
|
||||
}
|
||||
|
||||
// Upgrade of AFTER code snippet.
|
||||
// We cannot update this code snippet automatically. Show message that the upgrade has been skipped.
|
||||
// Upgrade of AFTER code snippet. We cannot update this code snippet
|
||||
// automatically. Show message that the upgrade has been skipped.
|
||||
$code_after = variable_get('googleanalytics_codesnippet_after', '');
|
||||
if (!empty($code_after)) {
|
||||
drupal_set_message(Database::getConnection()->prefixTables("Automatic upgrade of Google Analytics custom 'after' code snippet has been skipped. Backup of previous code snippet has been saved in database table '{variable}' as 'googleanalytics_codesnippet_after_backup_6300'. You need to manually upgrade the custom 'after' code snippet."), 'error');
|
||||
$messages[] = t('Skipped custom "after" code snippet.');
|
||||
}
|
||||
|
||||
return empty($messages) ? t('No custom code snipped found. Nothing to do.') : implode(' ', $messages);
|
||||
return empty($messages) ? t('No custom code snippet found. Nothing to do.') : implode(' ', $messages);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -356,18 +361,20 @@ function googleanalytics_update_7002() {
|
||||
$googleanalytics_custom_vars['slots'][1]['slot'] = 1;
|
||||
$googleanalytics_custom_vars['slots'][1]['name'] = 'User roles';
|
||||
$googleanalytics_custom_vars['slots'][1]['value'] = '[current-user:role-names]';
|
||||
$googleanalytics_custom_vars['slots'][1]['scope'] = 1; // Sets the scope to visitor-level.
|
||||
// Sets the scope to visitor-level.
|
||||
$googleanalytics_custom_vars['slots'][1]['scope'] = 1;
|
||||
|
||||
variable_set('googleanalytics_custom_var', $googleanalytics_custom_vars);
|
||||
return t('The deprecated profile segmentation setting for "User roles" has been added to custom variables. You need to deselect all selected profile fields in <a href="@admin">Google Analytics settings</a> and upgrade other profile fields manually or you may loose tracking data in future! See Google Analytics <a href="@customvar">Custom Variables</a> for more information.', array('@customvar' => 'https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingCustomVariables', '@admin' => url('admin/config/system/googleanalytics')));
|
||||
return t('The deprecated profile segmentation setting for "User roles" has been added to custom variables. You need to deselect all selected profile fields in <a href="@admin">Google Analytics settings</a> and upgrade other profile fields manually or you may lose tracking data in future! See Google Analytics <a href="@customvar">Custom Variables</a> for more information.', array('@customvar' => 'https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingCustomVariables', '@admin' => url('admin/config/system/googleanalytics')));
|
||||
}
|
||||
else {
|
||||
return t('You need to deselect all selected profile fields in <a href="@admin">Google Analytics settings</a> and upgrade other profile fields manually or you may loose tracking data in future! See Google Analytics <a href="@customvar">Custom Variables</a> for more information.', array('@customvar' => 'https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingCustomVariables', '@admin' => url('admin/config/system/googleanalytics')));
|
||||
return t('You need to deselect all selected profile fields in <a href="@admin">Google Analytics settings</a> and upgrade other profile fields manually or you may lose tracking data in future! See Google Analytics <a href="@customvar">Custom Variables</a> for more information.', array('@customvar' => 'https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingCustomVariables', '@admin' => url('admin/config/system/googleanalytics')));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename googleanalytics_trackoutgoing variable to googleanalytics_trackoutbound.
|
||||
* Rename googleanalytics_trackoutgoing variable to
|
||||
* googleanalytics_trackoutbound.
|
||||
*/
|
||||
function googleanalytics_update_7003() {
|
||||
variable_set('googleanalytics_trackoutbound', variable_get('googleanalytics_trackoutgoing', 1));
|
||||
@@ -377,7 +384,8 @@ function googleanalytics_update_7003() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename googleanalytics_visibility variable to googleanalytics_visibility_pages for consistency.
|
||||
* Rename googleanalytics_visibility variable to
|
||||
* googleanalytics_visibility_pages for consistency.
|
||||
*/
|
||||
function googleanalytics_update_7004() {
|
||||
variable_set('googleanalytics_visibility_pages', variable_get('googleanalytics_visibility', 1));
|
||||
@@ -401,7 +409,7 @@ function googleanalytics_update_7005() {
|
||||
|
||||
$diff = array_diff($pages, preg_split('/(\r\n?|\n)/', variable_get('googleanalytics_pages', implode("\n", $pages))));
|
||||
if (empty($diff)) {
|
||||
// No diff to previous settings found. Update with new settings.
|
||||
// No difference to previous settings found. Update with new settings.
|
||||
$pages = array(
|
||||
'admin',
|
||||
'admin/*',
|
||||
@@ -437,7 +445,8 @@ function googleanalytics_update_7007() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete custom ga.js code snipptes to prevent malfunctions in new Universal Analytics tracker. A backup of your snippets will be created.
|
||||
* Delete custom ga.js code snippets to prevent malfunctions in new Universal
|
||||
* Analytics tracker. A backup of your snippets will be created.
|
||||
*/
|
||||
function googleanalytics_update_7200() {
|
||||
$messages = array();
|
||||
@@ -459,11 +468,12 @@ function googleanalytics_update_7200() {
|
||||
$messages[] = t('Manual upgrade of custom "after" code snippet from ja.js to analytics.js API is required.');
|
||||
}
|
||||
|
||||
return empty($messages) ? t('No custom code snipped found. Nothing to do.') : implode(' ', $messages);
|
||||
return empty($messages) ? t('No custom code snippet found. Nothing to do.') : implode(' ', $messages);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete obsolete custom variables. Custom variables are now custom dimensions and metrics.
|
||||
* Delete obsolete custom variables. Custom variables are now custom dimensions
|
||||
* and metrics.
|
||||
*/
|
||||
function googleanalytics_update_7201() {
|
||||
variable_del('googleanalytics_custom_var');
|
||||
@@ -475,7 +485,7 @@ function googleanalytics_update_7201() {
|
||||
* Delete obsolete JavaScript scope variable.
|
||||
*/
|
||||
function googleanalytics_update_7202() {
|
||||
// Remove obsolete scope variable
|
||||
// Remove obsolete scope variable.
|
||||
variable_del('googleanalytics_js_scope');
|
||||
|
||||
return t('Removed obsolete JavaScript scope variable.');
|
||||
|
@@ -104,7 +104,7 @@ $(document).ready(function() {
|
||||
Drupal.googleanalytics.isCrossDomain = function (hostname, crossDomains) {
|
||||
/**
|
||||
* jQuery < 1.6.3 bug: $.inArray crushes IE6 and Chrome if second argument is
|
||||
* `null` or `undefined`, http://bugs.jquery.com/ticket/10076,
|
||||
* `null` or `undefined`, https://bugs.jquery.com/ticket/10076,
|
||||
* https://github.com/jquery/jquery/commit/a839af034db2bd934e4d4fa6758a3fed8de74174
|
||||
*
|
||||
* @todo: Remove/Refactor in D8
|
||||
@@ -163,8 +163,8 @@ Drupal.googleanalytics.isInternalSpecial = function (url) {
|
||||
* Extract the relative internal URL from an absolute internal URL.
|
||||
*
|
||||
* Examples:
|
||||
* - http://mydomain.com/node/1 -> /node/1
|
||||
* - http://example.com/foo/bar -> http://example.com/foo/bar
|
||||
* - https://mydomain.com/node/1 -> /node/1
|
||||
* - https://example.com/foo/bar -> https://example.com/foo/bar
|
||||
*
|
||||
* @param string url
|
||||
* The web url to check.
|
||||
|
@@ -7,7 +7,7 @@
|
||||
* Adds the required Javascript to all your Drupal pages to allow tracking by
|
||||
* the Google Analytics statistics package.
|
||||
*
|
||||
* @author: Alexander Hass <http://drupal.org/user/85918>
|
||||
* @author: Alexander Hass <https://drupal.org/user/85918>
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -17,7 +17,7 @@ define('GOOGLEANALYTICS_TRACKFILES_EXTENSIONS', '7z|aac|arc|arj|asf|asx|avi|bin|
|
||||
|
||||
/**
|
||||
* Define default path exclusion list to remove tracking from admin pages,
|
||||
* see http://drupal.org/node/34970 for more information.
|
||||
* see https://drupal.org/node/34970 for more information.
|
||||
*/
|
||||
define('GOOGLEANALYTICS_PAGES', "admin\nadmin/*\nbatch\nnode/add*\nnode/*/*\nuser/*/*");
|
||||
|
||||
@@ -36,7 +36,7 @@ function googleanalytics_api() {
|
||||
function googleanalytics_help($path, $arg) {
|
||||
switch ($path) {
|
||||
case 'admin/config/system/googleanalytics':
|
||||
return t('<a href="@ga_url">Google Analytics</a> is a free (registration required) website traffic and marketing effectiveness service.', array('@ga_url' => 'http://www.google.com/analytics/'));
|
||||
return t('<a href="@ga_url">Google Analytics</a> is a free (registration required) website traffic and marketing effectiveness service.', array('@ga_url' => 'https://marketingplatform.google.com/about/analytics/'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ function googleanalytics_menu() {
|
||||
* Implements hook_page_alter() to insert JavaScript to the appropriate scope/region of the page.
|
||||
*/
|
||||
function googleanalytics_page_alter(&$page) {
|
||||
global $user;
|
||||
global $base_path, $user;
|
||||
|
||||
$id = variable_get('googleanalytics_account', '');
|
||||
|
||||
@@ -134,7 +134,7 @@ function googleanalytics_page_alter(&$page) {
|
||||
$link_settings['trackColorbox'] = $track_colorbox;
|
||||
}
|
||||
if ($track_domain_mode = variable_get('googleanalytics_domain_mode', 0)) {
|
||||
$link_settings['trackDomainMode'] = $track_domain_mode;
|
||||
$link_settings['trackDomainMode'] = (int) $track_domain_mode;
|
||||
}
|
||||
if ($track_cross_domains = variable_get('googleanalytics_cross_domains', '')) {
|
||||
$link_settings['trackCrossDomains'] = preg_split('/(\r\n?|\n)/', $track_cross_domains);
|
||||
@@ -201,11 +201,23 @@ function googleanalytics_page_alter(&$page) {
|
||||
|
||||
// Track access denied (403) and file not found (404) pages.
|
||||
if ($status == '403 Forbidden') {
|
||||
// See http://www.google.com/support/analytics/bin/answer.py?answer=86927
|
||||
$url_custom = '"/403.html?page=" + document.location.pathname + document.location.search + "&from=" + document.referrer';
|
||||
// See https://www.google.com/support/analytics/bin/answer.py?answer=86927
|
||||
$url_custom = '"' . $base_path . '403.html?page=" + document.location.pathname + document.location.search + "&from=" + document.referrer';
|
||||
}
|
||||
elseif ($status == '404 Not Found') {
|
||||
$url_custom = '"/404.html?page=" + document.location.pathname + document.location.search + "&from=" + document.referrer';
|
||||
$url_custom = '"' . $base_path . '404.html?page=" + document.location.pathname + document.location.search + "&from=" + document.referrer';
|
||||
}
|
||||
|
||||
// #2693595: User has entered an invalid login and clicked on forgot
|
||||
// password link. This link contains the username or email address and may
|
||||
// get send to Google if we do not override it. Override only if 'name'
|
||||
// query param exists. Last custom url condition, this need to win.
|
||||
//
|
||||
// URLs to protect are:
|
||||
// - user/password?name=username
|
||||
// - user/password?name=foo@example.com
|
||||
if (arg(0) == 'user' && arg(1) == 'password' && array_key_exists('name', drupal_get_query_parameters())) {
|
||||
$url_custom = '"' . $base_path . 'user/password"';
|
||||
}
|
||||
|
||||
// Add custom dimensions and metrics.
|
||||
@@ -256,11 +268,10 @@ function googleanalytics_page_alter(&$page) {
|
||||
$script .= '})(window,document,"script",';
|
||||
|
||||
// Which version of the tracking library should be used?
|
||||
$library_tracker_url = '//www.google-analytics.com/' . ($debug ? 'analytics_debug.js' : 'analytics.js');
|
||||
$library_cache_url = 'http:' . $library_tracker_url;
|
||||
$library_tracker_url = 'https://www.google-analytics.com/' . ($debug ? 'analytics_debug.js' : 'analytics.js');
|
||||
|
||||
// Should a local cached copy of analytics.js be used?
|
||||
if (variable_get('googleanalytics_cache', 0) && $url = _googleanalytics_cache($library_cache_url)) {
|
||||
if (variable_get('googleanalytics_cache', 0) && $url = _googleanalytics_cache($library_tracker_url)) {
|
||||
// A dummy query-string is added to filenames, to gain control over
|
||||
// browser-caching. The string changes on every update or full cache
|
||||
// flush, forcing browsers to load a new copy of the files, as the
|
||||
@@ -462,7 +473,7 @@ function googleanalytics_user_presave(&$edit, $account, $category) {
|
||||
function googleanalytics_cron() {
|
||||
// Regenerate the tracking code file every day.
|
||||
if (REQUEST_TIME - variable_get('googleanalytics_last_cache', 0) >= 86400 && variable_get('googleanalytics_cache', 0)) {
|
||||
_googleanalytics_cache('http://www.google-analytics.com/analytics.js', TRUE);
|
||||
_googleanalytics_cache('https://www.google-analytics.com/analytics.js', TRUE);
|
||||
variable_set('googleanalytics_last_cache', REQUEST_TIME);
|
||||
}
|
||||
}
|
||||
@@ -485,7 +496,7 @@ function googleanalytics_preprocess_search_results(&$variables) {
|
||||
/**
|
||||
* Helper function for grabbing search keys. Function is missing in D7.
|
||||
*
|
||||
* http://api.drupal.org/api/function/search_get_keys/6
|
||||
* https://api.drupal.org/api/function/search_get_keys/6
|
||||
*/
|
||||
function googleanalytics_search_get_keys() {
|
||||
static $return;
|
||||
@@ -526,6 +537,10 @@ function _googleanalytics_cache($location, $synchronize = FALSE) {
|
||||
if ($data_hash_local != $data_hash_remote && file_prepare_directory($path)) {
|
||||
// Save updated tracking code file to disk.
|
||||
file_unmanaged_save_data($result->data, $file_destination, FILE_EXISTS_REPLACE);
|
||||
// Based on Drupal Core drupal_build_css_cache().
|
||||
if (variable_get('css_gzip_compression', TRUE) && variable_get('clean_url', 0) && extension_loaded('zlib')) {
|
||||
file_unmanaged_save_data(gzencode($result->data, 9, FORCE_GZIP), $file_destination . '.gz', FILE_EXISTS_REPLACE);
|
||||
}
|
||||
watchdog('googleanalytics', 'Locally cached tracking code file has been updated.', array(), WATCHDOG_INFO);
|
||||
|
||||
// Change query-strings on css/js files to enforce reload for all users.
|
||||
@@ -538,6 +553,10 @@ function _googleanalytics_cache($location, $synchronize = FALSE) {
|
||||
// There is no need to flush JS here as core refreshes JS caches
|
||||
// automatically, if new files are added.
|
||||
file_unmanaged_save_data($result->data, $file_destination, FILE_EXISTS_REPLACE);
|
||||
// Based on Drupal Core drupal_build_css_cache().
|
||||
if (variable_get('css_gzip_compression', TRUE) && variable_get('clean_url', 0) && extension_loaded('zlib')) {
|
||||
file_unmanaged_save_data(gzencode($result->data, 9, FORCE_GZIP), $file_destination . '.gz', FILE_EXISTS_REPLACE);
|
||||
}
|
||||
watchdog('googleanalytics', 'Locally cached tracking code file has been saved.', array(), WATCHDOG_INFO);
|
||||
|
||||
// Return the local JS file path.
|
||||
|
@@ -83,7 +83,7 @@ class GoogleAnalyticsBasicTest extends DrupalWebTestCase {
|
||||
// Verify that no tracking code is embedded into the webpage; if there is
|
||||
// only the module installed, but UA code not configured. See #2246991.
|
||||
$this->drupalGet('');
|
||||
$this->assertNoRaw('//www.google-analytics.com/analytics.js', '[testGoogleAnalyticsPageVisibility]: Tracking code is not displayed without UA code configured.');
|
||||
$this->assertNoRaw('https://www.google-analytics.com/analytics.js', '[testGoogleAnalyticsPageVisibility]: Tracking code is not displayed without UA code configured.');
|
||||
|
||||
$ua_code = 'UA-123456-1';
|
||||
variable_set('googleanalytics_account', $ua_code);
|
||||
@@ -104,7 +104,7 @@ class GoogleAnalyticsBasicTest extends DrupalWebTestCase {
|
||||
$this->assertNoRaw($ua_code, '[testGoogleAnalyticsPageVisibility]: Tracking code is not displayed on admin page.');
|
||||
$this->drupalGet('admin/config/system/googleanalytics');
|
||||
// Checking for tracking code URI here, as $ua_code is displayed in the form.
|
||||
$this->assertNoRaw('//www.google-analytics.com/analytics.js', '[testGoogleAnalyticsPageVisibility]: Tracking code is not displayed on admin subpage.');
|
||||
$this->assertNoRaw('https://www.google-analytics.com/analytics.js', '[testGoogleAnalyticsPageVisibility]: Tracking code is not displayed on admin subpage.');
|
||||
|
||||
// Test whether tracking code display is properly flipped.
|
||||
variable_set('googleanalytics_visibility_pages', 1);
|
||||
@@ -112,7 +112,7 @@ class GoogleAnalyticsBasicTest extends DrupalWebTestCase {
|
||||
$this->assertRaw($ua_code, '[testGoogleAnalyticsPageVisibility]: Tracking code is displayed on admin page.');
|
||||
$this->drupalGet('admin/config/system/googleanalytics');
|
||||
// Checking for tracking code URI here, as $ua_code is displayed in the form.
|
||||
$this->assertRaw('//www.google-analytics.com/analytics.js', '[testGoogleAnalyticsPageVisibility]: Tracking code is displayed on admin subpage.');
|
||||
$this->assertRaw('https://www.google-analytics.com/analytics.js', '[testGoogleAnalyticsPageVisibility]: Tracking code is displayed on admin subpage.');
|
||||
$this->drupalGet('');
|
||||
$this->assertNoRaw($ua_code, '[testGoogleAnalyticsPageVisibility]: Tracking code is NOT displayed on front page.');
|
||||
|
||||
@@ -126,13 +126,15 @@ class GoogleAnalyticsBasicTest extends DrupalWebTestCase {
|
||||
// Enable tracking code for all user roles.
|
||||
variable_set('googleanalytics_roles', array());
|
||||
|
||||
$base_path = base_path();
|
||||
|
||||
// Test whether 403 forbidden tracking code is shown if user has no access.
|
||||
$this->drupalGet('admin');
|
||||
$this->assertRaw('/403.html', '[testGoogleAnalyticsPageVisibility]: 403 Forbidden tracking code shown if user has no access.');
|
||||
$this->assertRaw($base_path . '403.html', '[testGoogleAnalyticsPageVisibility]: 403 Forbidden tracking code shown if user has no access.');
|
||||
|
||||
// Test whether 404 not found tracking code is shown on non-existent pages.
|
||||
$this->drupalGet($this->randomName(64));
|
||||
$this->assertRaw('/404.html', '[testGoogleAnalyticsPageVisibility]: 404 Not Found tracking code shown on non-existent page.');
|
||||
$this->assertRaw($base_path . '404.html', '[testGoogleAnalyticsPageVisibility]: 404 Not Found tracking code shown on non-existent page.');
|
||||
|
||||
// DNT Tests:
|
||||
// Enable system internal page cache for anonymous users.
|
||||
@@ -168,7 +170,7 @@ class GoogleAnalyticsBasicTest extends DrupalWebTestCase {
|
||||
(function(q,u,i,c,k){window['GoogleAnalyticsObject']=q;
|
||||
window[q]=window[q]||function(){(window[q].q=window[q].q||[]).push(arguments)},
|
||||
window[q].l=1*new Date();c=i.createElement(u),k=i.getElementsByTagName(u)[0];
|
||||
c.async=true;c.src='//www.google-analytics.com/analytics.js';
|
||||
c.async=true;c.src='https://www.google-analytics.com/analytics.js';
|
||||
k.parentNode.insertBefore(c,k)})('ga','script',document);
|
||||
ga('create', 'UA-123456-7');
|
||||
ga('send', 'pageview');
|
||||
@@ -179,7 +181,7 @@ class GoogleAnalyticsBasicTest extends DrupalWebTestCase {
|
||||
// Test whether tracking code uses latest JS.
|
||||
variable_set('googleanalytics_cache', 0);
|
||||
$this->drupalGet('');
|
||||
$this->assertRaw('//www.google-analytics.com/analytics.js', '[testGoogleAnalyticsTrackingCode]: Latest tracking code used.');
|
||||
$this->assertRaw('https://www.google-analytics.com/analytics.js', '[testGoogleAnalyticsTrackingCode]: Latest tracking code used.');
|
||||
|
||||
// Test whether anonymize visitors IP address feature has been enabled.
|
||||
variable_set('googleanalytics_tracker_anonymizeip', 0);
|
||||
@@ -256,13 +258,14 @@ class GoogleAnalyticsBasicTest extends DrupalWebTestCase {
|
||||
$this->assertRaw('ga("create", "' . $ua_code . '", {"cookieDomain":"auto","allowLinker":true', '[testGoogleAnalyticsTrackingCode]: "allowLinker" has been found. Cross domain tracking is active.');
|
||||
$this->assertRaw('ga("require", "linker");', '[testGoogleAnalyticsTrackingCode]: Require linker has been found. Cross domain tracking is active.');
|
||||
$this->assertRaw('ga("linker:autoLink", ["www.example.com","www.example.net"]);', '[testGoogleAnalyticsTrackingCode]: "linker:autoLink" has been found. Cross domain tracking is active.');
|
||||
$this->assertRaw('"trackDomainMode":2,', '[testGoogleAnalyticsTrackingCode]: Domain mode value is of type integer.');
|
||||
$this->assertRaw('"trackCrossDomains":["www.example.com","www.example.net"]', '[testGoogleAnalyticsTrackingCode]: Cross domain tracking with www.example.com and www.example.net is active.');
|
||||
variable_set('googleanalytics_domain_mode', 0);
|
||||
|
||||
// Test whether debugging script has been enabled.
|
||||
variable_set('googleanalytics_debug', 1);
|
||||
$this->drupalGet('');
|
||||
$this->assertRaw('//www.google-analytics.com/analytics_debug.js', '[testGoogleAnalyticsTrackingCode]: Google debugging script has been enabled.');
|
||||
$this->assertRaw('https://www.google-analytics.com/analytics_debug.js', '[testGoogleAnalyticsTrackingCode]: Google debugging script has been enabled.');
|
||||
|
||||
// Check if text and link is shown on 'Status Reports' page.
|
||||
// Requires 'administer site configuration' permission.
|
||||
@@ -272,7 +275,7 @@ class GoogleAnalyticsBasicTest extends DrupalWebTestCase {
|
||||
// Test whether debugging script has been disabled.
|
||||
variable_set('googleanalytics_debug', 0);
|
||||
$this->drupalGet('');
|
||||
$this->assertRaw('//www.google-analytics.com/analytics.js', '[testGoogleAnalyticsTrackingCode]: Google debugging script has been disabled.');
|
||||
$this->assertRaw('https://www.google-analytics.com/analytics.js', '[testGoogleAnalyticsTrackingCode]: Google debugging script has been disabled.');
|
||||
|
||||
// Test whether the CREATE and BEFORE and AFTER code is added to the tracker.
|
||||
$codesnippet_create = array(
|
||||
@@ -473,6 +476,51 @@ class GoogleAnalyticsCustomDimensionsAndMetricsTest extends DrupalWebTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test custom url functionality of Google Analytics module.
|
||||
*/
|
||||
class GoogleAnalyticsCustomUrls extends DrupalWebTestCase {
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Google Analytics custom url tests',
|
||||
'description' => 'Test custom url functionality of Google Analytics module.',
|
||||
'group' => 'Google Analytics',
|
||||
);
|
||||
}
|
||||
|
||||
function setUp() {
|
||||
parent::setUp('googleanalytics');
|
||||
|
||||
$permissions = array(
|
||||
'access administration pages',
|
||||
'administer google analytics',
|
||||
);
|
||||
|
||||
// User to set up google_analytics.
|
||||
$this->admin_user = $this->drupalCreateUser($permissions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if user password page urls are overridden.
|
||||
*/
|
||||
public function testGoogleAnalyticsUserPasswordPage() {
|
||||
$base_path = base_path();
|
||||
$ua_code = 'UA-123456-4';
|
||||
variable_set('googleanalytics_account', $ua_code);
|
||||
|
||||
$this->drupalGet('user/password', array('query' => array('name' => 'foo')));
|
||||
$this->assertRaw('ga("set", "page", "' . $base_path . 'user/password"');
|
||||
|
||||
$this->drupalGet('user/password', array('query' => array('name' => 'foo@example.com')));
|
||||
$this->assertRaw('ga("set", "page", "' . $base_path . 'user/password"');
|
||||
|
||||
$this->drupalGet('user/password');
|
||||
$this->assertNoRaw('ga("set", "page",', '[testGoogleAnalyticsCustomUrls]: Custom url not set.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class GoogleAnalyticsStatusMessagesTest extends DrupalWebTestCase {
|
||||
|
||||
public static function getInfo() {
|
||||
@@ -510,7 +558,7 @@ class GoogleAnalyticsStatusMessagesTest extends DrupalWebTestCase {
|
||||
//drupal_set_message('Example status message.', 'status');
|
||||
//drupal_set_message('Example warning message.', 'warning');
|
||||
//drupal_set_message('Example error message.', 'error');
|
||||
//drupal_set_message('Example error <em>message</em> with html tags and <a href="http://example.com/">link</a>.', 'error');
|
||||
//drupal_set_message('Example error <em>message</em> with html tags and <a href="https://example.com/">link</a>.', 'error');
|
||||
//$this->drupalGet('');
|
||||
//$this->assertNoRaw('ga("send", "event", "Messages", "Status message", "Example status message.");', '[testGoogleAnalyticsStatusMessages]: Example status message is not enabled for tracking.');
|
||||
//$this->assertNoRaw('ga("send", "event", "Messages", "Warning message", "Example warning message.");', '[testGoogleAnalyticsStatusMessages]: Example warning message is not enabled for tracking.');
|
||||
@@ -734,13 +782,13 @@ class GoogleAnalyticsPhpFilterTest extends DrupalWebTestCase {
|
||||
// Check tracking code visibility.
|
||||
variable_set('googleanalytics_pages', '<?php return TRUE; ?>');
|
||||
$this->drupalGet('');
|
||||
$this->assertRaw('//www.google-analytics.com/analytics.js', '[testGoogleAnalyticsPhpFilter]: Tracking is displayed on frontpage page.');
|
||||
$this->assertRaw('https://www.google-analytics.com/analytics.js', '[testGoogleAnalyticsPhpFilter]: Tracking is displayed on frontpage page.');
|
||||
$this->drupalGet('admin');
|
||||
$this->assertRaw('//www.google-analytics.com/analytics.js', '[testGoogleAnalyticsPhpFilter]: Tracking is displayed on admin page.');
|
||||
$this->assertRaw('https://www.google-analytics.com/analytics.js', '[testGoogleAnalyticsPhpFilter]: Tracking is displayed on admin page.');
|
||||
|
||||
variable_set('googleanalytics_pages', '<?php return FALSE; ?>');
|
||||
$this->drupalGet('');
|
||||
$this->assertNoRaw('//www.google-analytics.com/analytics.js', '[testGoogleAnalyticsPhpFilter]: Tracking is not displayed on frontpage page.');
|
||||
$this->assertNoRaw('https://www.google-analytics.com/analytics.js', '[testGoogleAnalyticsPhpFilter]: Tracking is not displayed on frontpage page.');
|
||||
|
||||
// Test administration form.
|
||||
variable_set('googleanalytics_pages', '<?php return TRUE; ?>');
|
||||
|
@@ -77,7 +77,7 @@ $(document).ready(function() {
|
||||
Drupal.googleanalytics.test.assertTrue(Drupal.googleanalytics.isInternal(base_url + Drupal.settings.basePath + 'node/1?foo=bar'), "Link '" + base_url + Drupal.settings.basePath + "node/1?foo=bar' has been detected as internal link.");
|
||||
Drupal.googleanalytics.test.assertTrue(Drupal.googleanalytics.isInternal(base_url + Drupal.settings.basePath + 'node/1?foo=bar#foo'), "Link '" + base_url + Drupal.settings.basePath + "node/1?foo=bar#foo' has been detected as internal link.");
|
||||
Drupal.googleanalytics.test.assertTrue(Drupal.googleanalytics.isInternal(base_url + Drupal.settings.basePath + 'go/foo'), "Link '" + base_url + Drupal.settings.basePath + "go/foo' has been detected as internal link.");
|
||||
Drupal.googleanalytics.test.assertFalse(Drupal.googleanalytics.isInternal('http://example.com/node/3'), "Link 'http://example.com/node/3' has been detected as external link.");
|
||||
Drupal.googleanalytics.test.assertFalse(Drupal.googleanalytics.isInternal('https://example.com/node/3'), "Link 'https://example.com/node/3' has been detected as external link.");
|
||||
console.groupEnd();
|
||||
|
||||
console.group("Test 'isInternalSpecial':");
|
||||
@@ -86,9 +86,11 @@ $(document).ready(function() {
|
||||
console.groupEnd();
|
||||
|
||||
console.group("Test 'getPageUrl':");
|
||||
Drupal.googleanalytics.test.assertSame(base_path, Drupal.googleanalytics.getPageUrl(base_url + Drupal.settings.basePath + 'node/1'), "Absolute internal URL '" + Drupal.settings.basePath + "node/1' has been extracted from full qualified url '" + base_url + base_path + "'.");
|
||||
Drupal.googleanalytics.test.assertSame(base_path, Drupal.googleanalytics.getPageUrl(Drupal.settings.basePath + 'node/1'), "Absolute internal URL '" + Drupal.settings.basePath + "node/1' has been extracted from absolute url '" + base_path + "'.");
|
||||
Drupal.googleanalytics.test.assertSame('http://example.com/node/2', Drupal.googleanalytics.getPageUrl('http://example.com/node/2'), "Full qualified external url 'http://example.com/node/2' has been extracted.");
|
||||
Drupal.google_analytics.test.assertSame(base_path, Drupal.google_analytics.getPageUrl(window.location.href), "Absolute internal URL '" + base_path + "' has been extracted from full qualified url '" + window.location.href + "'.");
|
||||
Drupal.google_analytics.test.assertSame(base_path, Drupal.google_analytics.getPageUrl(base_path), "Absolute internal URL '" + base_path + "' has been extracted from absolute url '" + base_path + "'.");
|
||||
//Drupal.googleanalytics.test.assertSame(base_path, Drupal.googleanalytics.getPageUrl(base_url + Drupal.settings.basePath + 'node/1'), "Absolute internal URL '" + Drupal.settings.basePath + "node/1' has been extracted from full qualified url '" + base_url + base_path + "'.");
|
||||
//Drupal.googleanalytics.test.assertSame(base_path, Drupal.googleanalytics.getPageUrl(Drupal.settings.basePath + 'node/1'), "Absolute internal URL '" + Drupal.settings.basePath + "node/1' has been extracted from absolute url '" + base_path + "'.");
|
||||
Drupal.googleanalytics.test.assertSame('https://example.com/node/2', Drupal.googleanalytics.getPageUrl('https://example.com/node/2'), "Full qualified external url 'https://example.com/node/2' has been extracted.");
|
||||
Drupal.googleanalytics.test.assertSame('//example.com/node/2', Drupal.googleanalytics.getPageUrl('//example.com/node/2'), "Full qualified external url '//example.com/node/2' has been extracted.");
|
||||
console.groupEnd();
|
||||
|
||||
@@ -105,9 +107,9 @@ $(document).ready(function() {
|
||||
if (Drupal.settings.googleanalytics.trackCrossDomains) {
|
||||
console.dir(Drupal.settings.googleanalytics.trackCrossDomains);
|
||||
Drupal.googleanalytics.test.assertTrue(Drupal.googleanalytics.isCrossDomain('example.com', Drupal.settings.googleanalytics.trackCrossDomains), "URL 'example.com' has been found in cross domain list.");
|
||||
Drupal.googleanalytics.test.assertTrue(Drupal.googleanalytics.isCrossDomain('example.net', Drupal.settings.googleanalytics.trackCrossDomains), "URL 'example.com' has been found in cross domain list.");
|
||||
Drupal.googleanalytics.test.assertTrue(Drupal.googleanalytics.isCrossDomain('example.net', Drupal.settings.googleanalytics.trackCrossDomains), "URL 'example.net' has been found in cross domain list.");
|
||||
Drupal.googleanalytics.test.assertFalse(Drupal.googleanalytics.isCrossDomain('www.example.com', Drupal.settings.googleanalytics.trackCrossDomains), "URL 'www.example.com' not found in cross domain list.");
|
||||
Drupal.googleanalytics.test.assertFalse(Drupal.googleanalytics.isCrossDomain('www.example.net', Drupal.settings.googleanalytics.trackCrossDomains), "URL 'www.example.com' not found in cross domain list.");
|
||||
Drupal.googleanalytics.test.assertFalse(Drupal.googleanalytics.isCrossDomain('www.example.net', Drupal.settings.googleanalytics.trackCrossDomains), "URL 'www.example.net' not found in cross domain list.");
|
||||
}
|
||||
else {
|
||||
console.warn('Cross domain tracking is not enabled. Tests skipped.');
|
||||
|
@@ -13,7 +13,7 @@ function googleanalytics_variable_info($options) {
|
||||
'type' => 'string',
|
||||
'title' => t('Web Property ID', array(), $options),
|
||||
'default' => 'UA-',
|
||||
'description' => t('This ID is unique to each site you want to track separately, and is in the form of UA-xxxxxxx-yy. To get a Web Property ID, <a href="@analytics">register your site with Google Analytics</a>, or if you already have registered your site, go to your Google Analytics Settings page to see the ID next to every site profile. <a href="@webpropertyid">Find more information in the documentation</a>.', array('@analytics' => 'http://www.google.com/analytics/', '@webpropertyid' => url('https://developers.google.com/analytics/resources/concepts/gaConceptsAccounts', array('fragment' => 'webProperty'))), $options),
|
||||
'description' => t('This ID is unique to each site you want to track separately, and is in the form of UA-xxxxxxx-yy. To get a Web Property ID, <a href="@analytics">register your site with Google Analytics</a>, or if you already have registered your site, go to your Google Analytics Settings page to see the ID next to every site profile. <a href="@webpropertyid">Find more information in the documentation</a>.', array('@analytics' => 'https://marketingplatform.google.com/about/analytics/', '@webpropertyid' => url('https://developers.google.com/analytics/resources/concepts/gaConceptsAccounts', array('fragment' => 'webProperty'))), $options),
|
||||
'required' => TRUE,
|
||||
'group' => 'googleanalytics',
|
||||
'localize' => TRUE,
|
||||
|
Reference in New Issue
Block a user