1

I have some expanding sections (via .js) and I want to see when the user clicks those.

So, in the OnClick event I want to attach some .js to fire off a virtual pageview. (I know how to fire an Event but I want a Pageview so I can use it in Goals)

And here is the .js I'm using .

I suspect I can just change the 'event' parameter to something else (pageview ??)

    <script>

/**
* Function that tracks a click on an outbound link in Analytics.
*/
var trackOutboundLink = function(url) {
   ga('send', 'event', 'outbound', 'click', url, {
     'transport': 'beacon',
     'hitCallback': function(){document.location = url;}
   });
}
</script>
  • I added an answer bellow, did you try it? – brclz Oct 18 '16 at 13:27
1

According to Google Analytics Docs, "pageview hits can be sent using the send command and specifying a hitType of pageview"

Example in your case :

<script>

/**
 * Function that tracks a click on an outbound link in Analytics.
 */
var trackOutboundLink = function(url) {
   ga('send', 'pageview', url, {
     'transport': 'beacon',
     'hitCallback': function(){document.location = url;}
   });
}
</script>

I would test it, since I am not sure that hitCallbackis supported in this case. If not, Google suggest another (similar) format in its doc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.