Form tracking and Click tracking is not working for Iframe

Dear Sir/Madam,

Form tracking and Click tracking are not working for Iframe only.
If we are not using the iframe then it is working fine.
We are using SnowPlow version2 and please see below form tracking code.
window.snowplow(‘enableFormTracking’);

Thanks in Advance,
Ajay

Hi @Ajay_Kumar

Are you running the Snowplow Tracker within the iframe itself or on the parent page? To track things in the iframe, the tracker needs to be loaded on the page within the iframe, it should work fine then.

If not, if you can provide a reproducible example then I can investigate further.

Hi, Thanks for a quick reply.

Please see the below working and not working code.

Not working code
HTML Form in IFrame
window.snowplow(‘enableFormTracking’);

Working code

HTML Form

window.snowplow(‘enableFormTracking’);

Please let me know if you need any further information.
Thanks,
Ajay

Where is the snowplow tracker being added to the website? Is it on the page inside the iframe or only running on the parent page which hosts the iframe?

Hi,

Yes, it is added to the website. Tracker code is added to our website and there is a google form that is in Iframe.

Thanks

Hey Ajay,

I’ll jump in here as I’m still online.

I think you have your answer there - iframes don’t share the environment with the rest of the browser, they’re sandboxed - so it’s as if that content is in a separate browser altogether.

You’ll need to run the tracker initialisation script in the iframe before you can call any track methods from that environment. It’s a good idea to do some research on how iframes work, and the details of sharing data/cookies etc between iframes and their host pages too - it can be a tricky topic.

I hope that helps.

2 Likes