Multiple site IDs on the same page

Hi all,

I am trying to implement cross domain tracking and send data to one site ID in PP as well as sending data to a different site ID as per the structure here.

I have trouble using the Tag manager debug where the panel looks like this.

In Analytics debug events come in but I get javascript errors. Is it a problem to run two containers on the same website. GA has no trouble with multiple scripts. I assume I just don’t understand how PP does multiple scripts and how to debug. Single scripts work just fine. I humbly ask for advice.

Anders:)

Hi,
We have a great article on how to set up such an environment: How can I set up Piwik PRO for multiple environments? | Piwik PRO help center

As far as I can tell, the solution in the article evaluates the hostname and chooses a PP ID based on which hostname is present. Maybe I don’t get the support article, but I don’t think this covers my case.

I want PP on the exact same hostname to send data to two different PP IDs. One ID is for the roll-up, and the other one is for the individual site (hostname, if you will). I.e. all domains will have ID1. So, for instance, example-a.com will have ID1 and ID2, example-b.com will have ID1 and ID3, example-c.com will have ID1 and ID4, and so on.

I am running two different PP container scripts on the same domain, as described above. I do get data into the PP roll-up, but I get javascript errors and I don’t see the tag manager debug working.

@mbaersch You have helped before:)

The idea is to fire two different containers and send the same data to each. The two requests for containers work, the first two in the list. It appears that only one ppms.php request is triggered. Why don’t two ppms.php calls get sent? One for each container? Doesn’t PP support multiple containers like GA does? If PP does, is there a config that I haven’t used?

Here are two clips, where the two containers fire as expected. There is only one ppms.php request, and it seems to arbitrarily fire based on one or the other container.


Well, what I could also recommend from my side is to try to play around with the addTracker method that should deal with your issue.

I have no idea why two containers should be needed but however: two instances of PP might be the problem because they are using the same command queue and that could be the reason for your troubles. If so, one container would have to switch to the alternative namespace… maybe that helps? If my assumption is correct, you can compare cour problem to using PP and Matomo at the same time anf this the same fix could apply here as well. Can I use Piwik PRO and Matomo at the same time? | Piwik PRO help center

AFAIK there is no option to use _ppas instead of _paq, so you might need to deactivate all PP standard tags in one container and use costom html tags instead. But I am not sure about that.

best,
Markus

Hi, I seem to be a bit closer by using the addTracker method. I now see two ppms.php calls, but they both get 404. The payloads look good. Do you have any idea about why they get 404? The URLs are correct.

This is the part of the script where the trackers get added:

// Add trackers after the Piwik Pro script is loaded
tags.onload = function() {
window._paq = window._paq || ;
window._paq.push([‘setTrackerUrl’, ‘https://norges.containers.piwik.pro/ppms.php’]);
window._paq.push([‘setSiteId’, ‘19c287e6-e375-4b6c-b93b-038’]);
window._paq.push([“addTracker”, “https://norges.containers.piwik.pro/ppms.php”, “6cde5751-4441-4a1c-aae5-da1cd6”]);
};
})(window, document, ‘dataLayer’, ‘19c287e6-e375-4b6c-b93b-038’);

Remove containers from the tracker endpoint URL and I think it should be norgesgruppen not norges.

https://norgesgruppen.piwik.pro/ppms.php

Well, it was a clumsy attempt to anonymize the post. You can see the correct URL in the clip below that calls the …a1cd66837a7.js file.
.
This is a URL copied from a different installation script in the same account. https://norgesgruppen.containers.piwik.pro is correctly collecting data today.

When I use the standard manual installation script, I have no problems. It’s when I use the addTracker method the problem occurs.

This file should contain the content of your Piwik PRO Tag Manager container (stuff like tags and so on).

The https://norgesgruppen.piwik.pro/ppms.php endpoint is responsible for data collection and this is what we want to use in the addTracker method.

So something like _paq.push([“addTracker”, “https://norgesgruppen.piwik.pro/ppms.php”, “6cde5751-4441-4a1c-aae5-da1cd6”]); should do the trick when it comes to adding a second tracker.

By the way, if you want me to anonymize some stuff from this post - send me a private message.

I guess your suggestion is what I am using. ref the thread above.

These are called after the .js file has loaded.

// Add trackers after the Piwik Pro script is loaded
tags.onload = function() {
window._paq = window._paq || ;
window._paq.push([‘setTrackerUrl’, ‘https://norges.containers.piwik.pro/ppms.php’]);
window._paq.push([‘setSiteId’, ‘19c287e6-e375-4b6c-b93b-038’]);
window._paq.push([“addTracker”, “https://norges.containers.piwik.pro/ppms.php”, “6cde5751-4441-4a1c-aae5-da1cd6”]);
};
})(window, document, ‘dataLayer’, ‘19c287e6-e375-4b6c-b93b-038’);

The only difference is that mine are preceded with windows._paq…

Please see the clip above where two ppms.php calls are made, and they both get 404.

I follow your logic; the .js file will govern both ppms.php requests and use the .js setup. This is fine, but how do you make the requests valid?

And they contain containers which I pointed out here:

Sorry, I misread my dev tools info. Thanks for your patience. It’s working now. I get 202 responses. :smiley:

So, now I know how to send the same data to two places, which is great learning. However, my need is to have separate sets of tags on the same page, like you can in GTM.

That would mean calling two different containers on the same page. Is that possible?

No, 2 or more Piwik PRO containers on the same page is not currently possible. Perhaps a meta setup would partially address your needs.

Thanks for your answer.

My use case is that I need a “roll-up” to do crossdomain tracking for the login sequence. That involves many sites, but there is only need for a couple of tags.

Each site has other needs that should be taken care of for each of them. The only cross domain need is login.

Using GA this would be simple as you can run multiple GTM containers on one site, sending data of your choice to different GA4 properties.

This seems to be very complicated with PP. Or is it something that I am missing?

No, this use case is the opposite of what I seek. I.e., separate tags for two different endpoints.

The only way to do this afaik by now, is the Meta Sites&Apps in Analytics, where you can see all included data if you implement the relevant tags on all sites. Still, this does not support cross-domain tracking, which I am looking for. I would have wanted to see the sessionised use of the single-sign-on solution for some 15 different websites, where tags would only be used to collect login data to and from SSO.

It seems to me that the PP strategy of combining Analytics and Tag Manager in one code base at the same time does not support different tracking needs on the same page as GTM and GA do.

I do like PP’s integrated simplicity, but I think this is a drawback.

Well, the meta setup allows you to have separate tags on a single site because on the PPTM UI level you kind of have 2 different containers. They are later (when published) joined together in a single tag tree but I’m not sure if that’s a problem.

What I usually do in case there’s a need for both specific views (seperate sites/domain) and a cross-domain tracking view is create a single tracking code containing 2 addTracker methods. One for the separate site and one for the cross-domain one.

I have tried both having a single Piwik PRO Tag Manager container for all of the websites and using a meta setup to keep the separate containers and deploy the “double tracker” on each of those websites with ease. The second method allows you to keep all of the tags that need the per site separation and deploy additional tags on top of that. There’s a short description of this method here.

I usually stick to running a single tracking code when splitting traffic into 2 different sites but you could try keeping all of the default tracking tags and adding the cross-domain tracker through the meta setup. This is not something I’ve tried but I think it could address the tracking tag separation need.

Using custom code is for sure more complicated than using UI to configure stuff like this but it’s still possible. Maybe I’m missing the point here but the attached image from your opening post looks very similar to what I’m describing above.

I agree it could be simpler when it comes to the implementation but this approach has some drawbacks (Simo has a cool article on this topic).

Thanks Anthony.

I think I get it now. If I build my Login tag on the meta-level and specify a standardized dataLayer across sites for login events, can I get login activity from all involved sites while each has a separate set of tags in their respective Sites?

That would solve the absolute number of login events across sites, as I understand it, but without CDT?

You mention this:

In a way, it sounds like what I am after, but if you look at my intended setup here, the Script with ID 1 is, in effect, the tags in the Meta Sites&Apps. While Scripts ID 2 - 5 would be the actual scripts for each site?

With two addTracker methods, is there a way to choose which tags should fire? A trigger rule for Site ID?

No, cross-domain tracking still has to be enabled for one of the trackers (looks like Script w/ ID 1 in your case).

I think we should take a little step back just to make sure that we are on the same page here. We have to split up the Piwik PRO tracking code from the Piwik PRO container code. They are not tied to eachother permamently - you can use the TM without the tracking code and the tracking code without TM (e.g. embedding tracking in the source code, using a different tag manager).

The setup that I was talking about should look like this:

If we zoom in, and only inspect the tracker (leaving out tag managment stuff):




What I haven’t tried before, which may be the thing you are looking for, is this kind of setup:

To also address this question:

By default, if there are 2 trackers on the website and you e.g. use a custom event template in Piwik PRO Tag Manager, both of the trackers will receive the event. You can specify which site you want to send the custom event to using custom HTML tag.