i use Google Analytics with sub-domains and an iframe. The landing page on sub.mydomain.com contains an iframe with a registration form on www.mydomain.com.
The user clicks a banner sub.mydomain.com/landing?utm_source=so1&utm_medium=dis&utm_campaign=xe1&utm_content=re1
On the landing page, the registration form and the thankyou page this javascript code is used
var pageTracker = _gat._getTracker("UA-xxxxxx"); pageTracker._setDomainName(".mydomain.com"); pageTracker._setAllowHash(false); pageTracker._setAllowLinker(true); pageTracker._trackPageview();
on the landing page the iframe is loaded in the following way
var iframe = document.getElementById('register_iframe'); iframe.src = pageTracker._getLinkerUrl('http://www.mydomain.com/register.html');
The cookies on sub.mydomain.com and the registration iframe from www.mydomain.com both contain _utmz with utmcsr=so1|utmccn=xe1|utmcmd=dis|utmcct=re1
After submitting the the ajax form in the iframe the request for the thankyou page and some new javascript files still transfer the correct set __utmz cookie
the javascript from 2. on the thank you page then requests the __utm.gif but is now transferring .utmcsr=(direct)|utmccn=(direct)|utmcmd=(none) and the cookie on .mydomain.com is set to .utmcs开发者_Python百科r=(direct)|utmccn=(direct)|utmcmd=(none) too
As far as i know the ga code shouldn't overwrite a direct set source with direct or something else.
Thanks for any help
If Google Analytics Cross Domain Iframe Tracking is implemented as above, it should work.
I changed 2 things
I forgot to set in the iframe tracker code pageTracker._setAllowLinker(true);
I used on the landing page, that was hosted on a subdomain pageTracker._setDomainName("sub.mydomain.com"); i changed that to the same as on the main page in the iframe pageTracker._setDomainName(".mydomain.com");
As i understood the documentation that was not necessary, so don't know if that had an effect.
精彩评论