Skip to content

Commit c69ef8d

Browse files
committed
Updated for compatibility with Piwik v2.15 and included new registerEvents() hook for compatibility with Piwik 3.0
1 parent f546906 commit c69ef8d

File tree

3 files changed

+24
-13
lines changed

3 files changed

+24
-13
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ _paq.push(['setTrackerUrl', u+'piwik.php']);
3434
```
3535

3636
##Changelog
37+
0.1.2 Updated for compatibility with Piwik v2.15 and included new registerEvents() hook for compatibility with Piwik 3.0
3738
0.1.1 Version bump to activation Marketplace hook
3839
0.1.0 Initial Release
3940

TrackingCodeCustomizer.php

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,22 @@
3636

3737
class TrackingCodeCustomizer extends \Piwik\Plugin
3838
{
39-
public function getListHooksRegistered()
40-
{
41-
$hooks = array(
39+
private static $hooks = array(
4240
'Piwik.getJavascriptCode' => 'applyTrackingCodeCustomizations'
4341
);
44-
return $hooks;
42+
43+
//2.15 includes a new function for registering hooks. 2.15 wi
44+
public function registerEvents()
45+
{
46+
return self::$hooks;
47+
}
48+
49+
//Pre 2.15 hook registration. Will be removed in Piwik 3. Kept for backwards compatibility with 2.12.
50+
//Pre ver3 will still call this in addition to registerEvents.
51+
//From reviewing the Piwik source this shouldn't be an issue as the hooks are not additive and this call will just overwrite the registerEvents call.
52+
public function getListHooksRegistered()
53+
{
54+
return self::$hooks;
4555
}
4656

4757
/*
@@ -61,19 +71,19 @@ public function getListHooksRegistered()
6171
* @key bool customCampaignKeywordParam
6272
* @key bool doNotTrack
6373
**/
64-
public function applyTrackingCodeCustomizations($sysparams,$parameters){
74+
public function applyTrackingCodeCustomizations(&$sysparams,$parameters){
6575

6676
$originalSysparams = $sysparams;
6777

6878
$settings = API::getInstance();
6979

7080
$storedSettings = $settings->getSettings();
7181

72-
if($storedSettings["options"])
73-
$storedSettings["options"] .= $sysparams["options"];
74-
75-
if($storedSettings["optionsBeforeTrackerUrl"])
76-
$storedSettings["optionsBeforeTrackerUrl"] .=$sysparams["optionsBeforeTrackerUrl"];
82+
if(array_key_exists("options", $storedSettings))
83+
$storedSettings["options"] .= $sysparams["options"];
84+
85+
if(array_key_exists("optionsBeforeTrackerUrl", $storedSettings))
86+
$storedSettings["optionsBeforeTrackerUrl"] .=$sysparams["optionsBeforeTrackerUrl"];
7787

7888
$sysparams = array_merge($sysparams,$storedSettings);
7989

plugin.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"name": "TrackingCodeCustomizer",
3-
"version": "0.1.1",
4-
"license": "GPL v3",
3+
"version": "0.1.2",
4+
"license": "GPL v3+",
55
"keywords": ["tracking", "javascript tracking","customize tracking","customise tracking"],
66
"description": "Allows Piwik admininstrators to customize the tracking code that is autogenerated for users. This is useful for directing requests to the correct servers in a multi-server setup, include additional parameters in default tracking, or to perform conditional checks before initiating a tracking call. ",
77
"homepage": "https://github.com/jbrule/piwikplugin-TrackingCodeCustomizer",
88
"theme": false,
99
"require": {
10-
"piwik": ">=v2.9.0"
10+
"piwik": ">=v2.12.0"
1111
},
1212
"authors": [
1313
{

0 commit comments

Comments
 (0)