: Tracking an iframed page hosted on another domain with Google Analytics I've followed Google's instructions on tracking iframed content on another domain (http://code.google.com/apis/analytics/docs/tracking/gaTrackingSite.html#trackin
I've followed Google's instructions on tracking iframed content on another domain (http://code.google.com/apis/analytics/docs/tracking/gaTrackingSite.html#trackingIFrames) as best I can, yet there is still no data showing up in Analytics for the iframed page.
Parent page (http://www.blackangus.com/primeclub/):
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxxx-xx']);
_gaq.push(['_setDomainName', 'blackangus.com']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
var iframeLink = "http://www.fishbowl.com/clt/blckangus/lp/join/joinform.asp";
jQuery(function() {
_gaq.push(function() {
var pageTracker = _gat._getTrackerByName();
iframeLink = pageTracker._getLinkerUrl(iframeLink);
jQuery("#joinform").attr("src", iframeLink);
});
});
</script>
And the iframed page(http://www.fishbowl.com/clt/blckangus/lp/join/joinform.asp):
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxx-xx']);
_gaq.push(['_setDomainName', 'blackangus.com']);
_gaq.push(['_setAllowHash', 'false']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);
(function() { var ga = document.createElement('script');
ga.type = 'text/javascript';
ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga, s);
})();
</script>
What am I doing wrong? Why won't the iframed page show up in Analytics?
More posts by @Turnbaugh106
1 Comments
Sorted by latest first Latest Oldest Best
Interessting. Your scripts seems to do three things:
Add the GA snippet to the non-iframe page and execute the pagetracker
Add some fishy looking code insertion on gaq.push
Add the GA snippet to the iframe page and execute the pagetracker
Essentially what you need for the non-iframe is this:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XYZXYZ-XY']);
_gaq.push(['_setDomainName', 'blackangus.com']);
_gaq.push(['_setAllowHash', 'false']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
and the exact same to your iframe-page (since it's not located at blackangus.com):
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XYZXYZ-XY']);
_gaq.push(['_setDomainName', 'blackangus.com']);
_gaq.push(['_setAllowHash', 'false']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
But, this will count as two pageviews in your GA setup, since the iframe will also trigger a pageview. You need to setup a filter, which filters out the double pageviews.
And yes, you need to wait a couple of hours until the first results are displayed. Usually around 24 hours.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.