WordPress.org

Forums

WP-Piwik
[resolved] Track Across Subdomains (WP on Subdomain) (7 posts)

  1. claytondaley
    Member
    Posted 11 months ago #

    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:

    domain.com
    subdomain.domain.com

    ... 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 *.subdomain.domain.com.

    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.

    https://wordpress.org/plugins/wp-piwik/

  2. braekling
    Member
    Plugin Author

    Posted 11 months ago #

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

    I'll change this.

  3. braekling
    Member
    Plugin Author

    Posted 11 months ago #

    Done in 0.9.9.11.

  4. claytondaley
    Member
    Posted 11 months ago #

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

    _paq.push(["setCookieDomain", "*.purelyjuicers.com"]);

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

    _paq.push(["setDomains", ["*.claytondaley.com","*.daleyklippings.claytondaley.com"]]);

    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.

  5. braekling
    Member
    Plugin Author

    Posted 10 months ago #

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

  6. claytondaley
    Member
    Posted 10 months ago #

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

  7. braekling
    Member
    Plugin Author

    Posted 10 months ago #

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

Reply

You must log in to post.

About this Plugin

  • WP-Piwik
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.