Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

piwik.js: Cross domain tracking #2211

Closed
anonymous-piwik-user opened this Issue Mar 20, 2011 · 17 comments

Comments

Projects
None yet
7 participants
@anonymous-piwik-user
Copy link

commented Mar 20, 2011

(ticket description updated by @mattab)

The goal of this ticket is to be able to measure a unique user across several domain names, by having Piwik.js automatically forwarding the User ID for this user in the URL as a query parameter.

Details

First party cookie by design will be only created and available in this domain where they were created. To allow for accurate cross-domains reporting, we need a way to persist the UUID (unique identifier) in the first party cookie from one domain to another domain.

The solution is to implement a mechanism that automatically decorates DOM elements within the page, which are links, and will add a GET Parameter to links, with the User ID.

Note: this feature has been available in Google universal analytics forever, and is well documented here: Universal analytics cross domain tracking. (this is a must read!)

Maybe in Piwik we can support the following methods:

  • 'Decorate Utility Method'
  • 'Decorating HTML Links'
  • 'Cross Domain Auto Linking'
  • Linker parameters are only valid for 2 minutes after they are created. Avoids user being assigned to wrong user id when sharing URLs with others.

Notes

  • we probably should implement User ID #3490 first
  • tracking unique users across websites will only accurately track users that clicked from one website to another. If user visits both websites independently, he will be assigned two different User IDs.
  • Will not be done in MVP:
    • Tracking Across iFrames
    • Decorating HTML Forms
@robocoder

This comment has been minimized.

Copy link
Contributor

commented Mar 20, 2011

Cross-domain linking works by the referring site adding parameters to the URL which the receiving site parses. (It's a little trickier with form submissions, but also doable.)

The main limitation is that first party cookies cannot be shared across different top level domains, i.e., x.com and y.com.

If we implement this feature, I propose:

  • site would use setDomains('y.com')
  • copy the idsite, uuid (from the visitor cookie), referring URL and timestamp (from the referral conversion cookie), and (maybe) custom variables
  • setAllowLinker(true) (or perhaps a more obvious name to enable this feature, so as to not confuse with enableLinkTracking)
@robocoder

This comment has been minimized.

Copy link
Contributor

commented Mar 21, 2011

Maybe: tracker.enableCrossDomainLinker( boolCopyCookies );

@mattab

This comment has been minimized.

Copy link
Member

commented Mar 26, 2011

tracker.enableCrossDomainsLinker (with a "s") maybe?

was your idea to pass the parameters, automatically on all clicks to domains that were specified in setDomains('y.com') ?

I think it's a must have indeed (especially with Ecommerce sites).

@robocoder

This comment has been minimized.

Copy link
Contributor

commented Mar 26, 2011

I envision it being automatic.

@mattab

This comment has been minimized.

Copy link
Member

commented May 20, 2014

Notes
In GA it used to be done with:

_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowLinker', true]);

Update 2014: In Universal analytics it is done this way:

ga('require', 'linker'); // Load the plugin.

// Define which domains to autoLink.
ga(linker:autoLink, [3-party.com, 3-party-domain.com]); //add as many as you need third party sites

on third party domain add

ga(create, 'UA-XXXXXX-X', { allowLinker: true });

See also this forum post

@anonymous-piwik-user anonymous-piwik-user added this to the 2.x - The Great Piwik 2.x Backlog milestone Jul 8, 2014

@mattab mattab removed P: normal labels Aug 3, 2014

@mattab mattab modified the milestones: Mid term, Short term Aug 14, 2014

@mattab mattab added the Major label Aug 27, 2014

@mattab mattab modified the milestones: Short term, Piwik 2.7.0, Long term Aug 27, 2014

@mattab mattab removed the Major label Aug 28, 2014

@asafyish

This comment has been minimized.

Copy link

commented Nov 17, 2014

+1

1 similar comment
@pirate

This comment has been minimized.

Copy link

commented Nov 17, 2014

+1

@asafyish

This comment has been minimized.

Copy link

commented Nov 18, 2014

I think we can partially accomplish it by exposing a setVisitorId method on the JS tracker, it will still require manual work for reading, and transferring the visitor id between domains, but it's still better then the current situation.

@pirate

This comment has been minimized.

Copy link

commented Nov 18, 2014

Yes, I believe that's already done and the docs are here: http://piwik.org/docs/user-id/
What I'm hoping for is a native baked-in solution that generates a unique ID and appends it to all the links that go to alias domains on the page, so that we can consistently track the same user across multiple domains (not just subdomains).

@cemdev

This comment has been minimized.

Copy link

commented Feb 16, 2015

+100

@mattab mattab added Lower priority and removed Lower priority labels Dec 5, 2016

@mattab mattab modified the milestones: Long term, Mid term Dec 5, 2016

@mattab mattab modified the milestones: Backlog (Help wanted), 3.0.2 Jan 9, 2017

@mattab mattab removed the Lower priority label Jan 10, 2017

@mattab

This comment has been minimized.

Copy link
Member

commented Jan 22, 2017

PR: #11243

@mattab

This comment has been minimized.

Copy link
Member

commented Jan 22, 2017

Cross domain tracking is available in Piwik 3.0.2-b1 release.

To use it configure it as follows in the Piwik Tracker code:

_paq.push(['setDomains', ['domain-1.net', 'domain-2.net']]);
_paq.push(['enableCrossDomainLinking']);
_paq.push(['setSiteId', X]);

(when adding both these lines in domain-1.net and domain-2.net -> users clicking from either website to the other website, will be automatically recognised as the same visitor and tracked in the same visit in website id X)

@mattab

This comment has been minimized.

Copy link
Member

commented Jan 22, 2017

Before closing the issue:

  • Document cross domain feature in the JavaScript tracking guide
  • Add new FAQ
  • Create a separate issue for backend improvement: ensure that Visitor ID is the same across all visits of a given visitor and re-uses the last visitor id value set or similar
@tsteur

This comment has been minimized.

Copy link
Member

commented Jan 22, 2017

when adding both these lines in domain-1.net and domain-2.net

We need to clearly mention it needs to be enabled on all domains / websites

backend improvement: ensure that Visitor ID is the same across all visits of a given visitor and re-uses the last visitor id value set

We should do it actually as part of this issue, it is in most cases not working without it.

@mattab

This comment has been minimized.

Copy link
Member

commented Jan 24, 2017

Note: Cross Domain feature is also useful when the data is tracked into different websites in Piwik. In that case, there won't be just "one visit" created, but "one visit per website". The advantage of using cross domains is that those two visits across website IDs will have the same Visitor ID. Could be super useful and we need to mention it in docs 👍

@mattab

This comment has been minimized.

Copy link
Member

commented Jan 26, 2017

Important:

  • Need to add a new checkbox in JavaScript Tracker Code screen, to let users enable cross domain tracking which will 1) enable the setDomains existing checkbox automatically and 2) output in the code the _paq.push(['enableCrossDomainLinking']);

@mattab mattab self-assigned this Feb 21, 2017

mattab added a commit to matomo-org/developer-documentation that referenced this issue Feb 24, 2017

Tracking multiple domain names in the same website
To record users across multiple domain names in the same Piwik website, we need to setup what is called Cross Domain linking. Cross domain tracking in Piwik makes sure that when the visitor visits multiple websites and domain names, the visitor data will be stored in the same visit and that the visitor ID is reused across domain names. A typical use case where cross domain is needed is for example when an ecommerce online store is on www.awesome-shop.com and the ecommerce shopping cart technology is on another domain such as secure.cart.com.

Learn about setting up cross-domain tracking in our guide: How do I accurately measure a same visitor across multiple domain names (cross domain linking)?


Refs matomo-org/matomo#2211

@mattab mattab closed this Feb 24, 2017

mattab added a commit to matomo-org/developer-documentation that referenced this issue Mar 1, 2017

Tracking multiple domain names in the same website (#175)
* Tracking multiple domain names in the same website

To record users across multiple domain names in the same Piwik website, we need to setup what is called Cross Domain linking. Cross domain tracking in Piwik makes sure that when the visitor visits multiple websites and domain names, the visitor data will be stored in the same visit and that the visitor ID is reused across domain names. A typical use case where cross domain is needed is for example when an ecommerce online store is on www.awesome-shop.com and the ecommerce shopping cart technology is on another domain such as secure.cart.com.

Learn about setting up cross-domain tracking in our guide: How do I accurately measure a same visitor across multiple domain names (cross domain linking)?


Refs matomo-org/matomo#2211

* few minor changes

* Update tracking-javascript-guide.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.