From 2efe5c451575ece0f0203bc7224062d9fbfe94b0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Markus=20M=C3=A4chler?= <markus.maechler@bithost.ch>
Date: Mon, 11 May 2015 10:26:39 -0400
Subject: [PATCH] Fixes piwik limitation to track custom variables 4 and 5
 together with trackSiteSearch

---
 module/VuFind/src/VuFind/View/Helper/Root/Piwik.php | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/module/VuFind/src/VuFind/View/Helper/Root/Piwik.php b/module/VuFind/src/VuFind/View/Helper/Root/Piwik.php
index 99ea13b4ded..64ff02545a5 100644
--- a/module/VuFind/src/VuFind/View/Helper/Root/Piwik.php
+++ b/module/VuFind/src/VuFind/View/Helper/Root/Piwik.php
@@ -329,6 +329,13 @@ EOT;
         $i = 0;
         foreach ($customVars as $key => $value) {
             ++$i;
+
+            // Workaround to prevent overwriting of custom variables 4 and 5 by
+            // trackSiteSearch, see http://forum.piwik.org/read.php?2,115537,115538
+            if ($i === 4) {
+                $i = 6;
+            }
+
             $value = $escape($value);
             $code .= <<<EOT
 _paq.push(['setCustomVariable', $i, '$key', '$value', 'page']);
-- 
GitLab