Tracking across Domains and sub domains

HI Everyone,

I’m trying to consistenly track a user across domains and subdomains. I’ve read documentaion that is available on this but i have one question;

When i have the following code on the main domain in the main Javascript tracking tag as given by the admin screen on the Matomo web app;

_paq.push([‘setCookieDomain’, ‘*’]);

What is the equivalent code that goes on the subdomain (lets call it

  1. _paq.push([‘setCookieDomain’, ‘*’]); (this seems to fail as it cant set this on the subdomain)
  2. _paq.push([‘setCookieDomain’, ‘*’]); (am i now setting two cookie domains which defeats the purpose of this?)
  3. do i set then all to _paq.push([‘setCookieDomain’, ‘*’]) and remove the www
  4. something else!

EDIT - also we have a checkout on recharge which is
what would be the setCookieDomain we would need to place on this domain?

Thanks and sorry for the daft question,

Has anyone used the setCookieDomain code before?