Skip to main content

Behavior Tracking

Optimize Deprecation

Uniform Optimize has been deprecated and replaced by Context, a more powerful and flexible personalization solution. Optimize is not being discontinued at this time, but it will not receive updates or new features.

We do not recommend starting a new project with Optimize. If you have an existing project that uses Optimize, you can upgrade your project to Context at no cost using our upgrade guide. If you have any issues with this process you can contact our team.

Content or pages that have been tagged with behavior tagging, which influence how a visitor is classified, need to push these tags into the tracker.

To help facilitate behavior tracking in Vue, the UniformOptimizePlugin uses a Vue mixin to provide a convenience function to all components for behavior tracking.

After plugin installation, all components will have access to the behavior tracking function via:

this.$uniformOptimize.trackBehavior(intentTags)

Example usage:

note
Ensure that the `UniformOptimizePlugin` is installed
import Vue from 'vue';
import { UniformOptimizePlugin } from '@uniformdev/optimize-tracker-vue';
import trackerInstance from '../lib/localTracker';

Vue.use(UniformOptimizePlugin, {
trackerInstance,
});

new Vue({
// ...app options
});
Sample component with behavior tracking
<template>
<div>My Component with behavior tracking</div>
</template>

<script>
export default {
props: ['fields'],
mounted() {
this.$uniformOptimize.trackBehavior(this.fields.unfrmOptIntentTag);
},
}
</script>
tip

It is recommended to only use the $uniformOptimize.trackBehavior function on the client (browser). Calling the function during any event/method that executes during SSR will not affect behavior tracking.

info

Each component that renders content tagged for behavior needs to call the $uniformOptimize.trackBehavior function to work correctly for behavior tracking. During render, all behavior data tracked is combined and weighted into the visitor's intent scores.

For example, a page may have both a Hero tagged with intent1 and a Callout tagged with intent2. The visitor will receive an intent score in both intent1 and intent2 by visiting this page.

It is also possible to push arbitrary behavior into the tracker from within components by manually constructing the IntentTags object:

<template>
<div>My Component with behavior tracking</div>
</template>

<script>
import { IntentTagStrength } from '@uniformdev/optimize-common';

export default {
methods: {
// NOTE: you can create your intent tag wherever/however you please,
// this example only uses a method for illustrative purposes.
createIntentTag() {
// this will create an arbitrary intent tag that will track
// behavior related to the `lovesDocumentation` intent.
// The intent must be defined in your intent manifest.
const intentTag = {
intents: {
lovesDocumentation: { str: IntentTagStrength.Normal },
},
};
},
},
mounted() {
const intentTag = this.createIntentTag();
this.$uniformOptimize.trackBehavior(intentTag);
}
}
</script>
info

Behavior push events that are triggered from components that are descendants of a <personalize /> component will be ignored. The reason being that personalization has already occurred via the <personalize /> component and therefore pushing additional behavior from descendants would only artificially amplify this behavior. An example of this could be showing a marketing related Hero component to someone who is already classified as marketer.