Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Asynchronous JavaScript tracking code #1842

Closed
robocoder opened this Issue · 7 comments

2 participants

@robocoder
Collaborator

Provide fast asynchronous javascript tag in Piwik 1.1

See the new documentation in http://piwik.org/docs/javascript-tracking/#toc-asynchronous-tracking

@robocoder
Collaborator

(In [3374]) fixes #1842, refs #739 - implement asynchronous tracking (thanks Xaver); see updated documentation, http://piwik.org/doc/javascript-tracking/

@robocoder
Collaborator

(In [3375]) refs #1842, refs #739 - implement push functions

@mattab
Owner

Excellent!!!
Reopening, for few questions and reminders:

  • Ga tracking tag sets a script.type = 'text/javascript'; on the DOM node. we shoudl maybe do the same?
  • Why does the snippet on the doc doesn't contain the "https:" == document.location.protocol test? Is it relying on the browser to understand that //PIWIK_URL will load with the right protocol?
  • why is 'script' passed as a parameter to the anonymous function rather than harcoded in the 2 places it is used? It saves character space, but it isn't really a parameter as such... (same with the 'document' parameter?).
  • UI for 'show javascript tracking tag' should probably explain how to use the asynchronous version.
  • Should we make the asynchronous version the default one in the UI (during install and in the SitesManager)?
  • Documentation could clarify at the start that 2 distinct Tracking techniques exist. Not sure how we should organize it.
@robocoder
Collaborator

This was largely Xaver's code. I've updated the docs and opened a new ticket for the outstanding questions/ideas.

Replying to matt:

  • Ga tracking tag sets a script.type = 'text/javascript'; on the DOM node. we shoudl maybe do the same?

Yes, we should. This is required per HTML4 spec, but was optional in practice. Thus, in HTML5 'text/javascript' is the default if type is unspecified.

  • Why does the snippet on the doc doesn't contain the "https:" == document.location.protocol test? Is it relying on the browser to understand that //PIWIK_URL will load with the right protocol?

I've changed it to use the old code so that it's clearer. But it is a clever optimization. The URI spec contains rules to resolves URI references. In this case, it should use the document's base URI to determine the scheme, if not specified.

  • why is 'script' passed as a parameter to the anonymous function rather than harcoded in the 2 places it is used? It saves character space, but it isn't really a parameter as such... (same with the 'document' parameter?).

To save bytes. I've removed the parameters.

  • UI for 'show javascript tracking tag' should probably explain how to use the asynchronous version.
  • Should we make the asynchronous version the default one in the UI (during install and in the SitesManager)?
  • Documentation could clarify at the start that 2 distinct Tracking techniques exist. Not sure how we should organize it.

Opening a new ticket for these.

@robocoder
Collaborator

Replying to vipsoft:

In this case, it should use the document's base URI to determine the scheme, if not specified.

"it" == a conforming user agent.

@mattab
Owner

Thanks for the updates, looks good!

@mattab
Owner

see #1845

@robocoder robocoder added this to the Piwik 1.1 milestone
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.