Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#1842 closed Bug (fixed)

Asynchronous JavaScript tracking code

Reported by: vipsoft Owned by:
Priority: normal Milestone: Piwik 1.1
Component: UI - UX (AngularJS, twig, less) Keywords:
Cc: Sensitive: no

Description (last modified by matt)

Provide fast asynchronous javascript tag in Piwik 1.1

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

Change History (9)

comment:1 Changed 3 years ago by vipsoft (robocoder)

  • Resolution set to fixed
  • Status changed from new to closed

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

comment:2 Changed 3 years ago by vipsoft (robocoder)

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

comment:3 follow-up: Changed 3 years ago by matt (mattab)

  • Resolution fixed deleted
  • Status changed from closed to reopened

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.

comment:4 in reply to: ↑ 3 ; follow-up: Changed 3 years ago by vipsoft (robocoder)

  • Resolution set to fixed
  • Status changed from reopened to closed

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.

comment:5 in reply to: ↑ 4 Changed 3 years ago by vipsoft (robocoder)

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.

comment:6 Changed 3 years ago by matt (mattab)

Thanks for the updates, looks good!

comment:7 Changed 3 years ago by matt (mattab)

  • Description modified (diff)
Note: See TracTickets for help on using tickets.