How to correctly track the analytics when using iframe

Posted by Sherry Ann Hernandez on Pro Webmasters See other posts from Pro Webmasters or by Sherry Ann Hernandez
Published on 2012-11-03T07:53:13Z Indexed on 2012/11/03 11:19 UTC
Read the original article Hit count: 333

In our main aspx page we have this analytics code

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-1301114-2']);
  _gaq.push(['_setDomainName', 'florahospitality.com']);
  _gaq.push(['_setAllowLinker', true]);
  _gaq.push(['_trackPageview']);
  _gaq.push(function() {   
  var pageTracker = _gat._getTrackerByName();   
  var iframe = document.getElementById('reservationFrame');   
  iframe.src = pageTracker._getLinkerUrl('https://reservations.synxis.com/xbe/rez.aspx?Hotel=15159&template=flex&shell=flex&Chain=5375&locale=en&arrive=11/12/2012&depart=11/13/2012&adult=2&child=0&rooms=1&start=availresults&iata=&promo=&group='); });

  (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>

Then inside this aspx page is an iframe. Inside the iframe we setup this analytics code

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-1301114-2']);
  _gaq.push(['_setDomainName', 'reservations.synxis.com']);
  _gaq.push(['_setAllowLinker', true]);
  _gaq.push(['_trackPageview', 'AvailabilityResults']);

  (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>

The problem is I see to pageview when I go to find the AvailabilityResults page. The first one is a direct traffic and the other one is a cpc.

How come that they have different source? I was expecting that both of them is using a direct traffic.

© Pro Webmasters or respective owner

Related posts about google-analytics

Related posts about analytics