Skip to main content

Buying Intent

Buying Intent is a feature that captures interest in your product categories. Specify your categories by URL or JavaScript, add frequency, time, and interval, and Triggerbee will let you know which of your visitors fulfill the Intent.

Unlike Interest Profiles, another Triggerbee Interest Feature, Buying Intent, is useful for capturing Interest here and now (eg, someone is looking for Shoes today), rather than general Interest (eg., someone is generally interested in makeup and will continue to buy that over and over).

The Buying Intent concept consists of 4 parameters:

  • Category: The category to be tracked. It can be all pages that have the word "shoes" in the URL, "heels" in the breadcrumb, or another specific attribute. You can combine multiple phrases in the category setup.

  • Frequency: How many visits should happen on the Category before we consider it to be of interest

  • Interval: How much time should pass between each visit? Usually, we put 12 hours.

  • Time: How many days do the visits need to happen within, eg. do they all need to happen during a week to be considered showing interest, or shorter/longer time?

When the Buying Intent is fulfilled, an event will be added to that visitor. If the visitor is identified, Triggerbee can notify your CRM to take further action - ie, send an email. If the visitor is unidentified, you can select to display a campaign instead (or do nothing).

This is an example of a Buying Intent Setup

Notify my CRM (or display a campaign for unidentified visitors) when someone...

  • Visits a page containing the word "heels" or "boots"

  • 3 times

  • during 7 days

  • with at least 12 hours between each visit

Note: The Buying Intent feature will add one (1) cookie per category to keep track of the intent. See the list of cookies for full documentation.


How to set up the Buying Intent Workflow

Step 1. Add the Buying Intent script to your Client Script.

The buying intent script consists of two parts. The top part consists of "helper functions" that don't need to be adjusted. At the bottom, you must configure your categories, frequencies, and other parameters for each Intent Category "Customer specific". The parameters are:

Pageview Function

Create a function that checks each pageview for your category. In the code example, we simply check for the searchParameter in each pageview's path. If it's a match, we return true from the function. The function can check paths or any other data from your site.

Category Parameters

The category parameters define your categories. You can have one or many.

  • id: set a unique ID for each of your categories.

  • searchParameter: what to search for for this category in the pageview function

  • minOccurances: how many times a visitor should visit the category before a intent is fulfilled. Default is 3.

  • goal: the name of the intent event. This is what you'll see in the visitor feed and your CRM.

  • minimumInterval: how many hours between each visit. Default is 12 hours.

  • allowMultipleGoals: set to true if you wish the intent to be able to fulfill over and over.

When the script has been added to the site, you will start to see visitors getting the buying intent goals/events in the visitor feed. This takes as many days as you've set in the script, so usually 3+ days. After that, you can use your buying intent goal for targeting onsite experiences or ping your CRM. See how below the example script.

Buying Intent Script

/* START BUYING INTENT */
/* START HELPER FUNCTIONS */

/* One-time cleanup of old sliding cookies */
function clearOldSlidingCookiesOnce() {
try {
// If we’ve already cleaned once in this browser, do nothing
if (localStorage.getItem("mtr_slidingCookieMigrated") === "1") {
return;
}
} catch (e) {
// If localStorage is blocked, we still run cleanup each load
}

var cookies = document.cookie.split(";");
for (var i = 0; i < cookies.length; i++) {
var c = cookies[i].trim();
if (c.indexOf("mtr_slidingCookie-") === 0) {
var name = c.split("=")[0];
document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/;";
}
}

try {
localStorage.setItem("mtr_slidingCookieMigrated", "1");
} catch (e) {
// Ignore if localStorage write fails
}
}

var slidingCookie = function (settings) {

// Toggle: allow multiple goals or only once per person
var allowMultipleGoals = (typeof settings.allowMultipleGoals === "boolean")
? settings.allowMultipleGoals
: true; // default: true (many times)

var isTrue = function () {
var minutes = settings.minimumInterval;
var count = settings.minOccurances;

if (!minutes)
minutes = 0; /* Avoid "Invalid date" in list */

var list = filterList(minutes);

/* Return true if list is more than count */
return list.length >= count;
}

var filterList = function (minutes) {
var list = getList();
var now = getNow();
var isDirty = false;
/* Filter expired items from list */
for (var i = list.length - 1; i >= 0; i--) {
var validUntil = new Date(list[i]);
validUntil.setMinutes(validUntil.getMinutes() + minutes);
var isWithin = validUntil > now;
if (!isWithin) {
list.splice(i, 1);
isDirty = true;
}
}
if (isDirty)
setCookie(getCookieName(), JSON.stringify(list));
return list;
}

var incrementList = function () {
var list = getList();

/* Add current pageview to list */
list.push(getNow().toString());

/* Limit to 50 items (dates) in list */
if (list.length >= 50)
list.shift();

/* Save list */
setCookie(getCookieName(), JSON.stringify(list));

return list;
}

var getList = function () {

/* Get list */
var list = getCookie(getCookieName());
list = !list ? [] : list = JSON.parse(list);
return list;
}

var getCookieName = function () { return "mtr_slidingCookie-" + settings.id }

var getNow = function () {
var now = new Date();
return now;
}

var getCookie = function (name) {
var ca = document.cookie.split(';');
for (var i = 0, l = ca.length; i < l; i++) {
if (ca[i].match(new RegExp("\\b" + name + "="))) {
return decodeURIComponent(ca[i].split(name + '=')[1]);
}
}
return '';
}

var setCookie = function (name, value) {
var ex = new Date;
ex.setTime(ex.getTime() + (3600 * 1000 * 24) * 21);
document.cookie = name + "=" + value + ";expires=" + ex.toGMTString() + ";path=/;";
}

// Reset only this category’s cookie
var resetList = function () {
setCookie(getCookieName(), JSON.stringify([]));
}

/* * Constructor * */

/* Check and increment */
if (settings.callback()) {
var list = getList();

/* we only store PageView IF the time since last */
/* PageView is more than minimumInterval (seconds vs seconds here) */
var lastView = (list.length > 0) ? new Date(list[list.length - 1]) : Date.now();
var interval = Date.now() - lastView;
var intervalSeconds = parseInt(interval / 1000);
if (intervalSeconds > settings.minimumInterval || list.length == 0) {
incrementList();
}
}

/* Run final actions */
var boolCounterTrue = isTrue();
if (settings.isDebug) {
console.log('Action taken for ' + settings.goalName + ' more than ' + settings.minOccurances + ' times in ' + settings.minimumInterval + ' seconds?: ' + boolCounterTrue);
console.log(getList());
}
if (boolCounterTrue) {

/* Log goal – either once or many times depending on toggle */
if (settings.goalName) {
if (allowMultipleGoals) {
// Many times: always log when condition is met
if (settings.isDebug) {
console.log('Logging goal (multiple allowed) ' + settings.goalName);
}
mtr.goal(settings.goalName);
} else {
// Once per person: only log if not already present
if (mtr.getPerson().goals.indexOf(settings.goalName) === -1) {
if (settings.isDebug) {
console.log('Logging goal (once per person) ' + settings.goalName);
}
mtr.goal(settings.goalName);
} else if (settings.isDebug) {
console.log('Goal already logged for person, skipping: ' + settings.goalName);
}
}
}

/* Save boolean on window-namespace so other scripts can use it */
eval("window." + settings.id + " = true");

/* Reset this category so the counter restarts ONLY if multiple goals allowed */
if (allowMultipleGoals) {
resetList();

// If you want the current visit to count as first visit in the new window:
// resetList();
// incrementList();
}
}

return {};
};


function afterTriggerbeeReady(callback) {
var maxAttempts = 10;
var counter = 0;
checkIsInitialized();

function checkIsInitialized() {
if (typeof (window.mtr) !== "undefined" && typeof (window.triggerbee.widgets) !== "undefined") {
callback();
} else {
if (counter < maxAttempts) {
setTimeout(function () {
counter++;
checkIsInitialized();
}, 250);
}
}
}
}

/* Init sliding cookie */
afterTriggerbeeReady(function () {
// One-time cleanup of old cookies before new logic kicks in
clearOldSlidingCookiesOnce();

initSlidingCookie();

document.addEventListener('onTriggerbeeSpaPageChanged', function (e) {
initSlidingCookie();
});
})
/* END HELPER FUNCTIONS */





/* CUSTOMER SPECIFIC */

// Configure your pageview function here
function isPageView(searchParameter) {
return window.location.pathname.includes(searchParameter);
}

// Configure your category parameters here
function initSlidingCookie() {
const categories = [
{ id: "purchaseIntentCategoryOne", searchParameter: "categoryOne", minOccurances: 3, goal: "Buying Intent Category One", minimumInterval: 3600 * 12, allowMultipleGoals: true },
{ id: "purchaseIntentCategoryTwo", searchParameter: "categoryTwo", minOccurances: 3, goal: "Buying Intent Category Two", minimumInterval: 3600 * 12, allowMultipleGoals: true }
];


categories.forEach(category => {
new slidingCookie({
id: category.id,
minimumInterval: category.minimumInterval,
minOccurances: category.minOccurances,
callback: () => isPageView(category.searchParameter),
goalName: category.goal,
allowMultipleGoals: category.allowMultipleGoals,
isDebug: false
});
});
}

/* END BUYING INTENT */

How to set up a Buying Intent Automation to your CRM

You can notify your CRM whenever someone fulfills a Buying Intent goal, to send them an email or put a label on them. This is done via Triggerbee Automations.

  1. Create a new automation

  2. Add a goal as trigger for the automation and select your buying intent goal

  3. Select what action to perform in your CRM.

  4. Save.

How to set up a Buying Intent Audience

Target visitors with a certain intent by creating an audience with buying intent goals.

  1. Create a new Audience.

  2. Add a goal filter and configure your setup with the buying intent goal. Should the visitor have fulfilled intent at least once, twice, or more - and how recently?

  3. Save your Audience. It will now be available for targeting your Onsite Experiences.

Did this answer your question?