Support » Plugin: WP-Matomo (WP-Piwik) » Track Across Subdomains (WP on Subdomain)

  • Resolved claytondaley


    I forked a previous version of WP-Piwik to track users across subdomains (in concert with API upgrades that are now publicly available). Now that the feature is included in core, I was hoping to use that version.

    My issue is that my WP instance is already on a subdomain… and what I actually want to do is track users across subdomains of my parent domain. With the API (and thus my fork) this is possible. Specifically, you configure the URLs on your domain as follows:

    … then the API call will attach “*.” to the first domain in the list (the parent domain). It’s a bit of a hack, but it’s exactly the same logic used to populate the “Tracking Code” section of Piwik’s settings.

    For some reason, the core version of wp-piwik behaves differently. Every time I upgrade (and I’ve gone back-and-forth to verify), the SetCookiesDomain gets set to *

    If (and I’m just guessing) this occurs because you’re (internally to wp-piwik) adding the *. to the full WP domain, it could be fixed with a simple toggle “WP is on a subdomain” that knows to exclude the subdomain from the SetCookiesDomain.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author braekling


    Oh, sorry, I didn’t realize the API parameter to add the wildcard.

    I’ll change this.

    Plugin Author braekling


    Done in

    Thanks for working on this. When I use the Tracking section in Piwik Settings, tracking across subdomains adds a line like:

    _paq.push([“setCookieDomain”, “*”]);

    In the wp-piwik plugin, it adds a line like:

    _paq.push([“setDomains”, [“*”,”*”]]);

    It’s been a while so I’m rusty, but I pulled my Pull request back up and I think you want to use “mergeSubdomains” instead of “mergeAliasUrls” when making the API call.

    Plugin Author braekling


    Ok, I’m really sorry. I will check this again.

    No need to appologize. I support an open source project ( so I appreciate (more than most) the time you invest and am happy to help if I can.

    Plugin Author braekling


    Fixed in, added both options (merge sudomains & merge alias urls).

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Track Across Subdomains (WP on Subdomain)’ is closed to new replies.