Question

I just moved a website over to Universal Analytics and I'm having some trouble trying to track virtual pageviews.

The page I'm working on has a clickable map where content is loaded in dynamically once a location is clicked.

Here's a sample of the code I'm using to try and capture virtual pageviews via the clicks:

<a id="Dublin" onClick="ga('send', 'pageview', {'page': '/Map/Virtual/Dublin','title': 'Dublin'});"></a>

I then have this in my tracking code:

<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-0000000-1', 'mywebsite.com');
  ga('send', 'pageview');
</script>

I have the correct ID and website URL in the tracking code.

In my content drilldown I can't find any references to my /Virtual/ pages. Would appreciate some help from an Analytics ninja!

Thanks!

Was it helpful?

Solution

Answered - code above is correct as pointed out by MisterPhilip. Original tag code was missing a " character.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top