'Cross Domain Tracking through Embedded Content

I have cross domain tracking set up on my site, A.com so I can track conversions in my other site B.com in the GA for A.com .

But I have an iframe that I need to put on my site. It will embed a form that people will use to get to a link to my other domain (the one that is connected with cross domain tracking). That form is embedded from another domain, example.com. I was able to go into my dashboard on example.com and place my GTM code in the iframe.

Since that link will be embedded, it will no longer pickup the user, since the user will be technically coming from example.com and not my site anymore.

How can I track the users that go from A.com through the embedded form (example.com) to my other site, B.com?

Mainly I just want to be able to track user interactions on the embedded form, and conversion events on B.com.



Solution 1:[1]

If you can add your own code to the iframe (example.com), you can get it to talk to the parent domain (A.com) using the postMessage API:

https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage

If you set this up, you'll be able to track events on A.com as normal and then set up cross domain tracking with B.com.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Alistair