Ticket #1845 (new New feature)

Opened 18 months ago

Last modified 2 months ago

Improve Tracking Code admin screen: asynchronous code, other options

Reported by: vipsoft Owned by:
Priority: critical Milestone: 1.8 Piwik 1.8
Component: UI (templates, javascript) Keywords:
Cc: Sensitive: no

Description (last modified by matt) (diff)

We would like to propose an advanced page to allow users to generate a tailor made javascript code for their pages.

Some options that this Javascript Tracking tag generator would include are:

  • display the asynchronous code only (currently we only display the non async code)
  • A radio button to "Group Page Titles report by subdomain". Useful when tracking multiple subdomains in the same Piwik website. See #1657
  • A radio button to "Track unique visitors across subdomains of $WEBSITE_HOST". Would call .setDomains('.example.org');
    • This would also ensure clicks to sub domains are not tracked as outlinks.
  • Should we default to load the JS from /js/ instead of piwik.js? This has the advantage of using compression, expire headers, etc. will result in a faster experience for webservers that do not set expire headers on static JS files.
  • allow to customize the campaign and name and keyword parameters (similar to GA "My online campaigns from other providers use different tags than those used by Google Analytics"). Calls setCampaignNameKey and/or setCampaignKeywordKey

Others:

  • Explain to users that they might need to escape the code when pasting in a template system such as Smarty
  • Explain that on dynamic pages, code can be added to a footer file or similar
  • Update the documentation at: http://piwik.org/docs/javascript-tracking/ and other places, to use the asynchronous version
    • Could we use a JS plugin that allows to show both versions (async by default, tab above the code snippet allowing to switch to non async?)
  • Allow to enable "Ping on page" that will improve bounce rate metric by pinging Piwik regularly when the tab is on focus. see #2041

 http://www.tracewatch.com/doc/code

Change History

  Changed 18 months ago by vipsoft

  • description modified (diff)

  Changed 18 months ago by vipsoft

  • description modified (diff)

  Changed 18 months ago by JulienM

Could we display a notice about each method pros and cons to help the user pick a method tailored to its needs?

  Changed 17 months ago by matt

  • milestone changed from 1.x - Piwik 1.x to 1.2 - Piwik 1.2

see also #1657

  Changed 17 months ago by matt

  • priority changed from normal to major

  Changed 17 months ago by matt

  • component changed from Core to UI (templates, javascript)

  Changed 17 months ago by matt

  • milestone changed from 1.2 - Piwik 1.2 to 1.1 - Piwik 1.1

  Changed 17 months ago by matt

  • summary changed from Tracking Code Generator/Wizard to Improve Tracking Code admin screen: asynchronous code, other options

  Changed 17 months ago by halfdan

Taken from the Forum ( http://forum.piwik.org/read.php?2,63811,page=1#msg-69341), this generator looks pretty nice:

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

URL is fixed and for the site ID the website selector could be used. I really like that there's a minify option included.

  Changed 17 months ago by matt

Such JS tag config screen would have a checkbox "Track unique visitors across subdomains of $WEBSITE_HOST"

which would add the following line:

piwikTracker.setDomainName('.example.org') 

which will force 1st party cookie to be set across

all subdomains (see  http://dev.piwik.org/trac/ticket/409#comment:32 )

  Changed 16 months ago by matt

If we push the use of asynchronous tracking code, how do we update the documentation, since there will be 2 ways of configuring the tracker? For example, we could have an inlined panel with 2 tables that would display the same tracking code type in all panel. Or, we could simply only display the doc for the asynchronous code.

follow-up: ↓ 13   Changed 16 months ago by matt

I'm also wondering if we could, by default, load the JS from piwik/js/ ? Is there any known blockers from doing it by default (any misconfiguration/missing extension) that are not tested for or handled in all cases? we couldn't really add one more failure option at this level (the "there is no data" FAQ is already quite big).

in reply to: ↑ 12   Changed 16 months ago by vipsoft

Replying to matt:

I'm also wondering if we could, by default, load the JS from piwik/js/ ? Is there any known blockers from doing it by default (any misconfiguration/missing extension) that are not tested for or handled in all cases? we couldn't really add one more failure option at this level (the "there is no data" FAQ is already quite big).

The code that serves static files is fairly robust now (especially with the double compression problem fixed).

+1 Most users who run ABP use subscriptions. Imagine my surprise to see that the latest EasyPrivacy subscription still has piwik.js|php blocked, but ga.js was recently removed from the list. *boggle*

  Changed 16 months ago by matt

Oh that doesn't make much change at all! but maybe with 1st party cookies they will remove it directly.

we will leave the piwik.js for 1.2 but if all goes well we could def move to /js in 1.3, which this ticket will be in I think

  Changed 15 months ago by matt

There could also be an pre-checked option: tracker.setDomains('*.piwik.org');

which would ensure clicks to sub domains are not tracked as outlinks. Even, the JS tag could be pre-filled with the Alias URLs filled in for this website as to keep some domains appearing in the list when it is important (eg. tracked in a different website).

  Changed 15 months ago by vipsoft

Please add to the inline text and/or documentation/faq that the user may need to "escape" the pasted tracking code when using a template or an app with its own templating system.

  Changed 14 months ago by vipsoft

From #2182, we could inspect the main URL and alias URLs, to see if there are any secure URLs. An example, where a hosting provider might have a shared SSL certificate:

Thus: var pkBaseURL = (("https:" == document.location.protocol) ? "https://host123.example.net/~account/example.com/piwik/" : "http://example.com/piwik/");

  Changed 14 months ago by vipsoft

*scratch that* I made an assumption. To be more general, it would require a couple of new parameters (or settings, if you want it persistent) to specify the tracker URL (secure vs non-secure); default would be the current URL.

  Changed 13 months ago by matt

#2041 would also be a good candidate for JS tracking option

Also see #1657

  Changed 12 months ago by matt

  • priority changed from major to critical

  Changed 2 months ago by matt

  • description modified (diff)

Updating ticket description consolidated from comments.

  Changed 2 months ago by matt

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