Asynchronous javascript in piwik 1.1


(robdavies) #1

Hi

I have upgraded to piwik 1.1 (this morning) using the admin panel, its the release version rather than the beta versions.

First problem I came accross, was when I clicked on locations. It reported that GeoIP doesn’t have (I think its) showContent. I disabled the GeoIP plugin, enabled it and it worked ok. Even before that error occured, it still showed the location of users on the dashboard.

What I’m having problems with is the asyc javascript tracking. I’m using
http://piwik.revaxarts.com/generator.php
to generate the tracking code, the async option on this page generates the same code as you have in the documentation.

I have added two pages to my clients website, one with
script type=“text/javascript”>
var _paq = _paq || [];
(function(){
var u = ((“https:” == document.location.protocol) ? “https://www.avescosmetics.com/piwik/” : “http://www.avescosmetics.com/piwik/”);
_paq.push([‘setSideId’, 1]);
_paq.push([‘setTrackerUrl’, u + ‘piwik.php’]);
_paq.push([‘trackPageView’]);
var d = document,
g = d.createElement(‘script’),
s = d.getElementsByTagName(‘script’)[0];
g.type = ‘text/javascript’;
g.defer = true;
g.async = true;
g.src = u + ‘piwik.js’;
s.parentNode.insertBefore(g,s);
})();

and the second with

all other pages have the previous javascript tracking. On the first page, I found that the page was only tracked once, even if I reloaded the page, restarted the browser and viewed the page again. It still only reported one pageview. using firebug, piwik.js was being loaded, however the tracker wasn’t being triggered.

When using the second script, each pageview was being tracked. using firebug, the tracker was being triggered.

Please can you advise/help? Are these supposed to work the same?

Thanks,
Rob


#2

I have already reported 2 bugs with the code created by that generator - the first is that depending on your choice (async, async2, normal) it may be missing a forward-slash after the piwik directory name, I guess you must have manually fixed that it your first code above.

The other problem is when choosing the option ‘async’ the resulting code includes ‘setSideId’ (as in your example above) which should be ‘setSiteId’.

Hope that helps.


(robdavies) #3

Thanks for your reply.

I added the forward slash after reading your post about it (I checked in firebug first, it caused an error without adding the forward slash).

I will change the setSideID to setSiteID. I haven’t tried it yet, this sounds like the problem though.

Thanks for the help.
Rob