I'm trying to handle gtag.js in order to track page views,
It's working fine on standalone pages or in iframe inside the same parent domain but it doesn't work when the iframe parent is not on the same domain (working on firefox but not in chrome/chromium)
-
parent page : abc.domain.com
- iframe1: def.domain.com
- gtag page view ok
- iframe2: ghi.domain.com
- gtag page view ok
- iframe1: def.domain.com
-
parent page: abc.running.com
- iframe1: def.domain.com
- gtag page view not working
- iframe2: ghi.domain.com
- gtag page view not working
- iframe1: def.domain.com
I control domain.com, i don't control running.com, my iframe is just included in it with an external script
gtag page view ok = i can see the collect http request in network inspector
gtag page view not working = i cannot see the collect http request in network inspector on chrome/chromium but i'm able to see in on firefox
My gtag javascript code included in the iframe is pretty simple:
<script async src="https://www.googletagmanager.com/gtag/js?id=TAGID"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'TAGID', {
page_path: "/page1",
page_title: "Page 1"
});
</script>
I tried to add the cookie_flags fields but it's not changing anything
<script async src="https://www.googletagmanager.com/gtag/js?id=TAGID"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'TAGID', {
page_path: "/page1",
page_title: "Page 1",
cookie_flags: "samesite=none;domain=domain.com;secure",
});
</script>
from gtag subdomains in iframe
No comments:
Post a Comment