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-matomo-user opened this issue Mar 20, 2011 · 17 comments
Closed

piwik.js: Cross domain tracking #2211

anonymous-matomo-user opened this issue Mar 20, 2011 · 17 comments
Assignees
Labels
Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc.
Milestone

Comments

@anonymous-matomo-user
Copy link

(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

@robocoder
Copy link
Contributor

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
Copy link
Contributor

Maybe: tracker.enableCrossDomainLinker( boolCopyCookies );

@mattab
Copy link
Member

mattab 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
Copy link
Contributor

I envision it being automatic.

@mattab
Copy link
Member

mattab 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-matomo-user anonymous-matomo-user added this to the 2.x - The Great Piwik 2.x Backlog milestone Jul 8, 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
Copy link

+1

1 similar comment
@pirate
Copy link

pirate commented Nov 17, 2014

+1

@asafyish
Copy link

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
Copy link

pirate 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
Copy link

cemdev commented Feb 16, 2015

+100

@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
Copy link
Member

mattab commented Jan 22, 2017

PR: #11243

@mattab
Copy link
Member

mattab 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
Copy link
Member

mattab 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
Copy link
Member

tsteur 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
Copy link
Member

mattab 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
Copy link
Member

mattab 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
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 as completed 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

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
Labels
Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc.
Projects
None yet
Development

No branches or pull requests

7 participants