Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
212 views
in Technique[技术] by (71.8m points)

performance - Form inside iframe with cross domain doesn't connect to Google Analytics

I have this situation.

Inside https://www.toyota.it I have an iframe which connects to https://tfsi.toyota.it (you can see it a this link), which we will call Configurator page.

Inside Configurator Page I have a form with a button. This form sends info via POST to a target URL, which is https://tfsi-calculator.toyota-fs.it/, that we will call Calculator page.

Both Configurator and Calculator pages have the same GTM container installed, which I use to connect them to a Google Analytics property.

The issue is that Google Analytics property seems to be properly connected to Calculator page, but it doesn't register any hit.

Instead, if I open Configurator page outside https://www.toyota.it iframe, simply opening the page from browser, everything works as expected and Google Analytics register sources, events etc. from both Configurator and Calculator pages.

Thinking it could be a cross-domain issue, I tried changing the target URL of the form to an older version of Calculator page which is still hosted on toyota.it domain, and I saw that hits were actually registered on Google Analytics property.

So, since it seemed to be a a cross-domain issue (the iframe which contains Configurator page is hosted on toyota.it website but the page called after clicking on button form, the Calculator page, is on toyota-fs.it domain), I followed this Universal Analytics Guide to configure Google Analytics connection the right way but it's still not working at all.

Since both Configurator and Calculator pages are connected to the same GTM Container, I first tried the following code:

gtag('config', 'GA_MEASUREMENT_ID', {
  'linker': {
      'domains': ['toyota-fs.it'],
      'decorate_forms': true,
      'accept_incoming': true
    }
});
question from:https://stackoverflow.com/questions/65844898/form-inside-iframe-with-cross-domain-doesnt-connect-to-google-analytics

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...