-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpush_commands_d7.patch
34 lines (33 loc) · 1.41 KB
/
push_commands_d7.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
diff --git a/googleanalytics.module b/googleanalytics.module
index 77ef862..dfbc3ac 100644
--- a/googleanalytics.module
+++ b/googleanalytics.module
@@ -175,6 +175,17 @@ function googleanalytics_page_alter(&$page) {
$url_custom = '"/404.html?page=" + document.location.pathname + document.location.search + "&from=" + document.referrer';
}
+ // hook_googleanalytics_custom_url
+ $url_custom_replace = module_invoke_all('googleanalytics_custom_url');
+ if (!empty($url_custom_replace)) {
+ $url_custom = join(' ', $url_custom_replace);
+ }
+
+ // hook_googleanalytics_push_commands
+ // allow modules to add command arrays via _gaq.push();
+ // see http://code.google.com/apis/analytics/docs/gaJS/gaJSApi_gaq.html#_gaq.push
+ $push_commands = module_invoke_all('googleanalytics_push_commands');
+
// Add any custom code snippets if specified.
$codesnippet_before = variable_get('googleanalytics_codesnippet_before', '');
$codesnippet_after = variable_get('googleanalytics_codesnippet_after', '');
@@ -255,6 +266,11 @@ function googleanalytics_page_alter(&$page) {
else {
$script .= '_gaq.push(["_trackPageview", ' . $url_custom . ']);';
}
+ if (!empty($push_commands)) {
+ foreach ($push_commands as $command) {
+ $script .= "_gaq.push([$command]);";
+ }
+ }
if (!empty($codesnippet_after)) {
$script .= $codesnippet_after;
}