1

I have a ticket booking system in an iframe. I am tracking sales but the source of the sales is not being recorded. I'm trying to shed some light on why this might be.

The code on the parent page is as follows:

<script type="text/javascript">
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  function addiFrame(divId, url, opt_hash) {
    return function(tracker) {
      window.linker = window.linker || new window.gaplugins.Linker(tracker);
      var iFrame = document.createElement('iFrame');
      iFrame.src = window.linker.decorate(url, opt_hash);
      document.getElementById(divId).appendChild(iFrame);
    };
  }

  ga('create', 'XX-REDACTED-X', 'theparentwebsite.com');
  ga('send', 'pageview');
  ga(addiFrame('tickets-iframe', 'https://www.theticketwebsite.com/'));
</script>

I have access to the ticket website source code, so I can update if needs be. The script inside the iframe is as follows:

<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
   (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
   m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
   })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'XX-REDACTED-X', 'auto', {
    'allowLinker': true
  });
  ga('send', 'pageview');
  ga('send', 'event', 'Sales', 'Sale', 'Ticket sold');
  ga('require', 'ecommerce', 'ecommerce.js');
  ga('ecommerce:addTransaction', {
    'id': X
  });
  ga('ecommerce:addItem', {
    'id': X,
    'name': 'Tickets',
    'price': XX.XX
  });
  ga('ecommerce:send');
</script>
1
  • This behavior is expected. By trying to overcome-it your site might be penalized by Google as it is very similar to some black-hat SEO tricks.
    – ek9
    Commented Mar 26, 2014 at 14:19

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.