1

My content is being distributed all over the web as an iframe, and I wish to monitor on which pages I get my content viewed on.

I created a Google Analytics property to collect this data - even though GA properties are tied to a domain, and in my case there is no specific domain (as said - it's embedded in pages all over the web).

Because I have many pieces of content that I spread around the web, I hijacked the GA page view mechanism and I report customized information under the page view:

  • as the URI I provide an internal content ID that makes sense to me
  • as a page title I use my content's title

It looks like this:

<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', 'UA-XXXXXXXX-XX');
ga('send', 'pageview', {
    page: '/<my internal content ID>',
    title: '<my internal content name>'
});
</script>

At first it worked brilliantly and I could see for each piece of content - which pages it was viewed on, (under traffic sources in GA - medium=referral, source=hosting page - even for direct browsing... yummy!), but over time I noticed more and more cases in which this information was not available (I got medium=direct, source=not set) - but it only happened in some cases, which I didn't manage to isolate.

Does anyone have an idea of what I'm doing wrong?

I know I'm bending the traditional use-case of GA, but hey - this is what gets us people through the day - right?

Aamit
  • 181
  • 4
  • 16
  • To exclude the obvious - maybe people started calling your framed content directly ? You could include a bit of js that checks if your content is indeed displayed in a frame and set a custom dimension accordingly. – Eike Pierstorff Jul 27 '15 at 07:10
  • It's probably not the case, seeing as I managed to reproduce it myself using the embedded iframe... – Aamit Jul 27 '15 at 07:38

0 Answers0