Reputation: 86
I am using vue
, vue-analytics
trying to track google analytics campaign with parameters from the url in the component:
export default {
components: {
Onboarding,
Content,
},
name: 'Main',
mounted() {
this.$ga.page({
page: '/?utm_source=linkedin&utm_medium=personal_message&utm_campaign=innerworks_linkedin_002',
title: 'Main page',
});
},
};
But I can's see any updates in the campaign tab. Do I use ga tracking in the correct way to track the campaign using UTM parameters?
Upvotes: 1
Views: 3786
Reputation: 27729
I don't know about vue-analytics
but I am using vue-gtag.
If you want to use that here is how I am configuring it:
src/plugins/google-analytics.js
)import Vue from 'vue'
import VueGtag from 'vue-gtag'
if (['staging', 'production'].includes(process.env.VUE_APP_MODE)) {
Vue.use(VueGtag, {
config: {
id: process.env.VUE_GOOGLE_ANALYTICS_KEY,
params: { anonymize_ip: true }
}
})
}
And then I import it in main.js
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import '@/plugins/google-analytics' // <= HERE
Make sure to take a look to vue-gtag docs.
Take a look at Auto tracking to allow the plugin to track all your pages automatically.
Upvotes: 3