Best way to track subdomains with different tag manager setups

Hi

We have a site, with an editorial subdomain as a suffix. Think https://example.com and https://example.com/editor.

Background
The subdomain serves as a sort for admin/editorial backend, which means the user behaviour is quite different from the main site. Because of this I also need a somewhat different tracking-setup for the subdomain to track events related to this site and I want to keep these data seperate from the main site.

I’ve created two properties, one for the main site, and another for the subdomain. So far so good.

For reference both sites are developed and maintained by an external developer, and I am no an expert in webcoding. I am however well advised in Piwik and tracking in general, but just saying this as I can be making false assumptions about the sites codebase.

The issue
The problem is the functionality in these two sites are heavily integrated and in true SPA-fashion, it’ll only load editorial scripting and functionality and keep everything else.

This is where my problem lies, because the tags are not updated. We’ve managed to force tracking on the subdomain by manipulating the siteID to make sure data is fed correctly into the subdomain, but the tracker itself is not updated. This means tracking on the subdomain is controlled via the tag manager on the main site.

To make matters even more complicated there are scenarios, where the correct Piwik property is loaded for the subdomain, but that is only in edge-cases. Fx. if a user starts the session directly in editorial mode.

To add some background, we’ve discussed this issue internally to see if we can force the application to reload the Piwik tracker, but none of the solutions seems to be feasable without doing major changes to the codebase. I am also adament in using seperate properties for analytics.

My question what’s the best approach here.

  1. Can I force Piwik to load the correct property and tags? (It seems there might be a solution here, which I’ll check out when possible: How can I set up Piwik PRO for multiple environments? | Piwik PRO help center)
  2. Should I resolve to using the main sites tag manager and filtering the scripts to feed the correct data to the subdomain (this really seems like a bad solution as it could make the setup unnecessarily complicated and cumbersome).
  3. Is there another way?

I really appreciate any help!
Br.
Martin

Hi,

I do not have a similar set-up but it might be a solution for you to make sure that before any tag fires, a setSiteId() command (API — Piwik PRO Analytics Suite 18.23 documentation) is used to define the desired destination (by path for example). That should fix your SPA issues, too (at least I hope so).

You might need to fire that tag with every page load or history change and push an event to the dataLayer as a new trigger for your tags (yes: no automatic SPA page views for full control)… or keep your existing trigger concept, but use HTML for all Piwik PRO events instead of the standard tag templates.

best,
Markus