Different scripts for each subdomain

Hello.

I have a different Google Analytics 4 measurement ID for each domain/subdomain, but apparently Zaraz currently doesn’t have an option to manage scripts based on the URL. I can only add one, which is fired everywhere.

I found this {{ system.page.url.pathname }} on the Cloudflare Docs, but didn’t help because the measurement ID is different on each domain/subdomain and not URL path.

Hope I explained myself XD
So, how can I use different GA 4 measurement ID in Zaraz?

Thanks in advance

You should use {{ system.page.url.host }} or {{ system.page.url.hostname }} as these will allow you to check the domain/subdomain:

https://developers.cloudflare.com/zaraz/reference/properties-reference/

Thanks, it works, I just tested it now.

But how can I exclude the WordPress (URL path: /wp-admin & /wp-login.php) backend?

Thanks again.

You could add multiple conditions to any trigger with an AND operator between them, and do another match rule this time on {{ system.page.url.pathname }} and select not matches regex as your operation with a match string such as:

^/wp-(admin|login.php)

Adding to what Simon said, you can also block Zaraz (together with all tools loaded by it) on specific page using Page Rules: https://developers.cloudflare.com/zaraz/advanced/block-zaraz/

1 Like

I had this same problem. Solved it and captured the solution at the end of my post Cloudflare Zaraz - Using the HTTP Request Tool for Trigger setup / debug. Hope that helps.

The Cloudflare messiah, many thanks!

Hey nice website! I was looking for a PKM solution.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.