Mobile app version of vmapp.org
Login or Join
Heady270

: Google Analytics tracking on the same domain account through an iframe I have written an advertising system for a client that serves adverts on one website (say, www.adhost.com) as a small HTML

@Heady270

Posted in: #Analytics #Google #GoogleAnalytics #Iframe #Tracking

I have written an advertising system for a client that serves adverts on one website (say, adhost.com) as a small HTML page and a second website (say, addisplay.com) pulls this page in as an iframe to be displayed as an advertising banner. Google Analytics is present in the adverts in order to track clickthroughs, but the clicks are being tracked under adhost.com's profile because the clicks are occurring within the iframe and Analytics knows no better.

Would it be possible to make these clicks track under addisplay.com's profile, even though they are occurring within a page hosted on adhost.com? If so, how?

Thanks,
Alex

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Heady270

1 Comments

Sorted by latest first Latest Oldest Best

 

@Ogunnowo487

You would need to pass their account variable as a parameter to the iFrame. You could then grab it (via server side or JS) and throw it into the GA call.

<iframe src="adhost.com/displayad.php?ga=UA-XXXXXXXX-X">


.. in displayad.php:

var GAaccount = 'UA-XXXXXXXX-X'; // grabbed via server side or custom JS function
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', GAaccount]);
// ...
</script>


This will get you at least pageviews for the ads. You'll probably want to do a couple of other things:


Since the cookies will be on different domains (one on addisplay.com and one on adhost.com) you'll also want to do things like _gaq.push(['_setAllowLinker', true]); and an onclick with _gaq.push(['_link', 'ad.destination.url']). This will keep the visitor's session across the domains.
Add on extra campaign details using utm_source,utm_medium,etc. You can easily build these links here of you so desire - I'd strongly suggest doing this.


Like eduardocereto mentioned, this isn't the best way to go about this... but hopefully this helps.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme