Here we will explore how to set up tracking of experiments in Variate for Vue.
By default, Variate will track all visitors unless they enabled navigator.doNotTrack.
To control the enablement of tracking, use the following line:
Vue.use(Variate, {
tracking: {
enabled: false, // If set to false, no tracking events will be triggered by Variate
},
...
});Potential use cases:
- Ability to track only visitors who have opted in to being tracked (e.g. GDPR controls).
- You prefer to use your own tracking mechanism while letting Variate control targeting, randomized bucketing and persistence of the experience.
To track any event in Variate, follow this pattern:
this.$variate.track(name, type, [value])Example: to track a click on a button
this.$variate.track('myButton_click', 'custom')Example: to track a purchase
this.$variate.track('purchase', 'revenue', 20.00)Below are the types of events to track when using Variate:
| type | description |
|---|---|
pageview |
Triggered every time a visitor meets the following criteria for any active experiments:
|
custom |
Manually set up to track any of the following:
|
revenue |
In addition to tracking purchase events as custom events, you have the option to send revenue data using a revenue event |
By default, when a visitor passes all qualification criteria for an active experiment (view, audience, bucketing), the pageview event will be triggered. Where you decide to send the pageview event is up to you and is covered in Reporting.
If you followed the Quick Start, you may have initialized Variate as follows:
Vue.use(Variate, {
debug: true,
config,
});If you prefer to track pageviews manually (for all experiments), then add pageview: false as follows:
Vue.use(Variate, {
debug: true,
pageview: false, // Pageviews will not be automatically recorded
config,
});If set to false, it is up to you to send the pageview event manually, for every experiment.
To send a pageview manually, use the following syntax, as seen inside of a component:
methods: {
variateTrackPageview() {
this.$variate.track({
name: 'Pageview',
type: 'pageview',
value: this.$variate.experiments
});
}
},
mounted() {
this.variateTrackPageview();
}To track a custom event, use the following syntax:
this.$variate.track({
name: 'myCustomEventName',
type: 'custom'
});Custom events are not associated to a specific experiment, since a single visitor may be qualified into multiple experiments. Also, an event may be triggered far from where the visitor originally qualified into an experiment. Therefore, a single event might show up in the reporting for multiple experiments.
To send revenue data, use the following syntax:
this.$variate.track({
name: 'myPurchaseEvent',
type: 'revenue',
value: 29.99
});