![Murray155](https://vmapp.org/images/player/000default.jpg)
: Generate Virtual Pageview via .js OnClick event in Google Analytics 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
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>
More posts by @Murray155
1 Comments
Sorted by latest first Latest Oldest Best
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.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.