Hi guys,
Trying to get my 404 page tracking with the asynchronous code however when I add the code detailed here it fully stops my ability to track. When I add that code tracking stops all together.
Any ideas?
I also have the current old Piwik tracking code which has some custom PHP stuff, how would I go ahead and switch it over?
<!-- Piwik -->
<script type="text/javascript">
var pkBaseURL = (("https:" == document.location.protocol) ? "https://stats.example.com/" : "http://stats.example.com/");
document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
</script><script type="text/javascript">
try {
var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 18);
<?php
$category = get_the_category();
if (!is_front_page() && !empty($category[1])) {
echo 'piwikTracker.setCustomVariable(1, "Category", "'.$category[1]->cat_name.'", "page");
';
echo 'piwikTracker.setCustomVariable(2, "Sub-Category", "'.$category[0]->cat_name.'", "page");';
}
elseif (!is_front_page() && !empty($category[0])) {
echo 'piwikTracker.setCustomVariable(1, "Category", "'.$category[0]->cat_name.'", "page");';
}
if (is_404()) {
echo 'piwikTracker.setDocumentTitle(\'404/URL = \'+String(document.location.pathname+document.location.search).replace(/\//g,"%2f") + \'/From = \' + String(document.referrer).replace(/\//g,"%2f"));';
}
?>