Search code examples
iframegoogle-analyticsanalytics

How to track iFrame pageviews with Google Analytics?


I have a Chrome Extension that re-designs the new tab. Each new tab loads content as an iFrame from tab.mywebsite.com.

When visiting tab.mywebsite.com, Google Analytics will track the pageview. However, when tab.mywebsite.com is loaded as an iFrame on new tabs, pageviews are not counted.

It may seem like this question has been answered before, but I have searched for a couple days and tried a couple solutions that don't seem to work at all. I tried this solution that suggests Google Tag Manager but it did not work as intended.

There seems to be a lot of conflicting ideas out there and wanted to see if anyone can point in the right direction.

Any thoughts on this are appreciated thanks.


Solution

  • For anyone who may have a similar question I actually found the way to include GA tracking in this other Stackoverflow question. It was a matter of setting content_security_policy in the manifest.json file and linking a js file with the Analytics code. See the solution in the linked question.