Asynchronous Tracking

Thanks for making the code generator, I did find it useful.

One problem, I believe the generated code is missing a forward-slash after the URL. In the top box where you can enter your URL it shows the forward slash outside the input field indicating the user should not enter a forward slash, but in the generated code it is not including the forward-slash, which I believe is necessary otherwise the code will not work (although the async2 version is correctly including the forward-slash)

Thank you very much
I try to look at the test.

[quote=Xaver]
I made a “quick 'n dirty” version of a codegenerator:

http:\piwik.revaxarts.com/generator.php

maybe someone find it useful[/quote]

Hello Xaver,

I used it and found it very useful.

Thank you,
George Brown.

I found another bug in the code generator, when using the method ‘async’ it generated a setting ‘setSideId’ that should be instead be ‘setSiteId’

Code won’t work without that fix :slight_smile:

Hi Leo!

Sorry for the late response. I’m busy at the moment.

Thanks for reporting the bugs - I fixed them. Unfortunately as I sad its only a quick n dirty version, but should work as expected. Maybe I can refine it later…

Because its a total client side version, feel free to copy the source code and modify it as much as you like.

Hi guys,

I’m sorry for kicking this dead body of a forum thread, but I think it’s still is the best (and the only one so far) thread for asynchronous tracking related points.

I have following questions to the asynchronous tracking (refers to the Piwik 1.12 release):

1. Asynchronous Tracker Code Location
The tracker examples on http://piwik.org/docs/javascript-tracking/#toc-where-can-i-find-the-piwik-tracking-code and also in the …index.php?module=CoreAdminHome&action=trackingCodeGenerator… part of one’s own Piwik installation have been updated to the new asynchronous tracker. But they still suggest placing the tracker before the tag, instead of before the tag, as e.g. Google suggests with its asynchronous tracker in Syntax Comparisons  |  Analytics for Web (ga.js)  |  Google Developers. Is that by design, or just a forgotten documentation update?

2. Fallback Image Tracker Location
If one uses the new asynchronous tracker code, places it before the as Google suggests and wants to use the image tracker as a no-script fallback between the tags, where would you then suggest placing that image tracker code: together with the asynchronous tracker before the tag, or at its previous location (with the old synchronous tracker) before the tag?

3. Disadvantages of the Asynchronous Tracker
The advantages of the asynchronous tracking have been widely documented. But does the asynchronous tracker have any disadvantages? E.g. with legacy and/or non-mainstream (e.g. older mobile) browsers?
E.g.: It seems that, although the “async” attribute was first introduced in HTML5, the addition of the “defer” attribute to the asynchronous tracker is supposed to provide a fallback for legacy browsers (see HTML Standard) - but only if they support the “defer” (see its history in the answer to javascript - Defer Attribute (Chrome) - Stack Overflow). Otherwise the script would block the page loading.
Is there anything else to be concerned about related to the new asynchronous tracker, e.g. for very old and/or exotic browsers, e.g. DOM related issues, etc.? I.e. if they don’t already have a problem with the old synchronous tracker.
Or is the asynchronous tracker, if placed just before the at the end of the page, in the worst case (i.e. if blocking page load with legacy/non-mainstream browsers) at least as good as the old synchronous tracker, while being better in most cases (i.e. with most modern browsers; although by a negligible time difference)?

Thanks in advance!

  1. by design. It’s more safe to put in the /body rather than HEAD

  2. fallback + main code, we recommend before /body

  3. one limitation is you can’t use multiple trackers (ie. tracking in 2 piwik site on the same page) with async