Mobile app version of vmapp.org
Login or Join
Sims2060225

: Google analytics in E-commerce iframe not tracking source 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

@Sims2060225

Posted in: #GoogleAnalytics #Javascript

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>

10% popularity Vote Up Vote Down


Login to follow query

More posts by @Sims2060225

0 Comments

Sorted by latest first Latest Oldest Best

Back to top | Use Dark Theme