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?