We have an tracking issue when our page is iframed.
Basically, we have a website: https://www.ourwebsite.com
Our website contains the following code in the head section:
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', {
trackingId: "UA-FOOBAR-1",
cookieDomain: 'auto',
tenantCode: "someString"
});
ga('send', 'pageview');
This works fine, and I see a corresponding request to https://www.google-analytics.com/j/collect when the page load:
Screenshot of Chrome Network Tab
However, when this same page is in an iframe:
<iframe id="iframe" src="https://www.ourwebsite.com" scrolling="no" style="width: 100% !important; min-width: 100% !important; overflow: hidden;"></iframe>
The request to the google analytics /collect endpoint is missing from the Chrome Network Tab, and we do not see the pageview event in the browser.
If the iframe src is changed from https to http, I start seeing reqeusts to /collect again.
The parent document is using the same scheme as the iframe (uses https when the iframe uses https, and uses http when the iframe is on http)
Full page source of ourwebsite.com:
<!DOCTYPE html>
<html lang="en">
<head>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', {
trackingId: "UA-FOOBAR-1",
cookieDomain: 'auto',
tenantCode: "someString"
});
ga('send', 'pageview');
</script>
</head>
<body class="ui-mobile">
</body>
</html>