Proxy/load ppms.js using the server-side-template-for-gtm in GTM Client side & SS

Hey :slight_smile:

I was really excited to see the new client template for Google Tagmanager Serverside on the Piwik Github.

I’m trying to proxy/load my Piwik setup in a first-party context using Server-side GTM, with anonymous tracking and the session hash!

However, I’m running into some challenges getting it to work. What am i missing?

How should I set up the Piwik Base tag in my Client-side GTM to ensure that both ppms.php and ppms.js are loaded in a first-party context?

I can see that both https://sgtm.my-domain.com/ppms.js and https://sgtm.my-domain.com/ppms.php are responding, but I’m having trouble getting them to work together.

Below is my setup:

GTM Client side:

Client in GTM SS side to load Piwik ressources within a first party context

GTM SS TAG

Fingers crossed for some feedback!

Br

Hi @dkv!

So for the Use a custom tracker URL setting you have to add the tracking endpoint URL which ends with /ppms.php.

As for loading the ppms.js file (the Piwik PRO JavaScript Tracking Client) from a first party domain, you have to first enable the Disable injection of the tracking client.

(explanation, you can skip this part)
Now, the issue with client-side GTM templates is that you can’t pull external scripts from any domain you want. You basically have to define the domain(s) in the template configuration which makes it hard to be compatible with each user setup (we’d have to whitelist thousands of domains that our users use).
(end of explanation)

What you basically have to do, is create a custom HTML tag and inject the script yourself. It’s best to use the same trigger that you have used for the Basic tracking code tag (Page view from what I can see) and also make sure that it’s prioritized/added before it.

Below you can find an example of how the custom HTML could look like. Just make sure to replace yoursgtmendpoint.domain.com.

We’ll update the documentation as this should’ve been described there.

Wow anthonybartczak!

That was a blazing fast reply!

Spend several hours trying to get it to work.

Now it works! Appreciate your support!

Br