Skip to content
This repository

Option to track with virtual pageviews #15

Closed
chhib opened this Issue · 3 comments

2 participants

David Andersson Eduardo Cereto Carvalho
David Andersson

Say, file downloads, we often track with virtual pageviews:
/virtual/download/readme.pdf

This is because we see these type of files, semantically, as page views, they often open in the browser or some kind of viewer. We apply this to outbound links as well. This comes with the benefit of setting upp great goal funnels, which still is pretty limited with events.

Would be great to be able to alter something along the lines:
_gas.push(['_trackOutboundLinks', {method: 'pageview', path: '/virtual/external-link/'}]);
_gas.push(['_trackOutboundLinks', {method: 'event', category: 'External Link'}]);

Eduardo Cereto Carvalho

I definitively would like to have that feature. But I think the best approach would bo to fire a VPV in addition to the Event. So we have a full report with all downloads and VPVs for those that we consider pages. You can currently do both in GAS using Hooks. So I wonder if the best approach to solve this bug is to document this method to fix using Hooks or to add an option to _trackOutboundLinks. The correct way to do it using hooks is:

_gas.push(['_addHook', '_trackEvent', function(cat, act, lab, val){
    if (cat === 'Download') {
        var vpv_extensions = ['doc', 'pdf'];
        if(vpv_extensions.indexOf(act) > -1) {
            _gas.push(['_trackPageview', '/download/' + lab]);
           //return false; // You may want to return false here to cancel the Event
        }
    }
    return [cat, act, lab, val];
}]);

Hooks are a very flexible and power feature of GAS that could use some better documentation.

Eduardo Cereto Carvalho

As for Outbound links I don't think it's a good use case. Outbound links as VPV is usually a bad practice. If you want to do that I'd say that you should write a hook to change the outbound link to a vpv.

For Downloads I agree there are good use cases and an option should be added.

Eduardo Cereto Carvalho

Decided not to implement it. Should be handled as hooks when this is needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.