How to pass SPA version in Google Analytics and VueJS?

Viewed 370

I have a VueJS SPA in which I have defined a build version that I can easily access as a javascript variable.

I have used VueGtag (https://github.com/MatteoGabriele/vue-gtag) to integrate Google Analytics with my SPA. I would like to view reports in Google Analytics for build version, so I can keep track with version adoption.

I've read about Custom Variables, but I can't see to get this to work and passed over to Google Analytics. Here is what I have at the moment:

Vue.use(VueGtag, {
    config: {
        id: "UA-XXXXXXX-X" 
    },
}, router);

And in my main App.vue, I have this in mounted():

this.$gtag.customMap({ 'dimension1': 'version' });
this.$gtag.event('version_event', { version: buildTs });

I have already confirmed that buildTs exists and is accessible in App.vue. However, I don't see any reporting of 'version' in GA.

1 Answers

You need to go into GA and under the settings for that property, create a new dimension to track the version. enter image description here

Take note of the "index" of that custom dimension. It will represent "dimensionX", in your gtag code.

Also, I'd recommend to pick the "session" scope, this just means that the dimension will be the same for the whole session. More info on scope: https://support.google.com/analytics/answer/2709828?hl=en

Related