-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgoogle_analytics_counter.api.php
47 lines (42 loc) · 1.41 KB
/
google_analytics_counter.api.php
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
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
/**
* @file
* Hooks provided by the Google Analytics Counter module.
*/
/**
* Alter Select query before it gets executed
*
* Here you can customize the select query which writes into the proper storage table
* the number of pageviews for each node
*
* @param SelectQuery $query
* Query builder for SELECT statements.
*/
function hook_google_analytics_counter_query_alter(&$query) {
// e.g. Restrict node pageview storage to node type: blog
$query->condition('type', 'blog', 'LIKE');
}
/**
* Alter $request array before retrieving data from Google.
*
* Alter request query submitted to google and provide custom filters or parameters
* For more information on how to customize requests to Google Analytics:
* @see https://ga-dev-tools.appspot.com/query-explorer/
*
* @param array $request
* Array with request options.
*/
function hook_google_analytics_counter_request_alter(&$request) {
// e.g. Only get stats for records from 15th of February, 2014 onwards (instead of 2005, which is the default date)
$request['start_date'] = strtotime('2014-02-15');
// e.g. Grab only stats for URLs which start with /blog/
$request['filters'] = "ga:pagePath=~^/blog/";
}
/**
* Informs other modules about which nodes have been updated.
*
* @param array $updated_nids
* Associative array with the new pageview total keyed by the nid.
*/
function hook_google_analytics_counter_update($updated_nids) {
}