Demandbase Integration
Target High-Value Accounts: Integrate Demandbase Data with Convert for Precision Personalization
THIS ARTICLE WILL HELP YOU:
- Before you start
- Install the Demandbase tracking code
- Build the audience you want to target from Demandbase data
- Add the wait helper to your Project Global JS
- Configure your experience to fire when Demandbase data is ready
- Run a QA in your experience
- Option 2: Fire the Location with the Manually trigger
- Migrate from the legacy recheck token
- If your plan doesn't include Dynamic Website Triggers (legacy)
Overview
Demandbase is a data aggregator for companies to personalize websites and email campaigns based on this data.
Convert can use the data provided to run experiences for chosen segments, such as companies or a specific industry.
Because Demandbase loads its data asynchronously, the experience has to wait until that data exists. Convert handles this with the When a callback is called Location trigger, which starts the experience once the data is there. It replaces the legacy convert_recheck_experiment() token, which is being phased out. The developer docs cover the same switch in Migrate to Dynamic Location Triggers.
Before you start
- Your project must use the current Convert tracking script. Dynamic Website Triggers (DOM Element, Manual and Callback) are not supported by the legacy script.
- When a callback is called is one of the Dynamic Website Triggers. If your plan includes Dynamic Website Triggers, follow the steps below. If it doesn't, use the legacy method at the end of this article. The Convert pricing page shows what each plan includes.
- You need a Demandbase account and access to its tracking code.
Install the Demandbase tracking code
Install the Demandbase tracking code on the web pages you want to personalize. It should load before the Convert tracking code, so the Demandbase data is available as early as possible.
Build the audience you want to target from Demandbase data
See Demandbase's Firmographic Attributes Overview for the data available to you. You can also type the following in the console of a web page where Demandbase is installed to see what is available:
Demandbase.Segments
For example, you can get the visitor's company information if you type:
Demandbase.Segments.CompanyProfile
From this you can start creating conditions to create segments. For example, this condition targets companies with a small number of employees:
Demandbase.Segments.CompanyProfile.employee_range == "Small"
Add the wait helper to your Project Global JS
In your project settings, add this helper to the Project Global JS. It checks every 100 ms (up to 50 times, about 5 seconds) for the Demandbase company profile. You only need to add it once per project. Save it under All Environments. If one of your environments has its own Global JS, add the helper there too, because that script replaces the All Environments code on that environment.
window.waitForDemandbase = ({
nextRetry = 100, // ms
maxRetries = 50,
} = {}) => {
let retries = 0;
const check = (resolve) => {
const profile = window?.Demandbase?.Segments?.CompanyProfile;
if (profile) {
resolve(profile);
} else if (retries < maxRetries) {
retries++;
setTimeout(() => check(resolve), nextRetry);
} else {
resolve();
}
};
return new Promise((resolve) => check(resolve));
};
Configure your experience to fire when Demandbase data is ready
Create your experience and your changes, if you have not done so.
First, edit the experience's Location settings, choose When a callback is called as the trigger, and paste this code:
if (options.isActive) return;
window.waitForDemandbase().then((profile) => {
if (profile) {
activate();
}
});
Convert passes two arguments to the callback: activate, which you call when the experience should start, and options, which includes locationId and isActive. The isActive check stops the callback from running twice. If Demandbase data never appears within the retry window, the experience does not activate. For more on this trigger, see Targeting Experiments with Dynamic Location Triggers (JS Callbacks).
Then, in the experience's audience settings, select New Audience and open the Advanced tab to add your condition. Add it as a JS Condition. Because the callback only activates the experience once the data exists, the condition no longer needs to check whether Demandbase has loaded. Its code should look like this:
(function () {
var profile = window.Demandbase && Demandbase.Segments && Demandbase.Segments.CompanyProfile;
return !!profile && profile.employee_range == "Small";
})()
Replace employee_range == "Small" with the attribute and value for your segment.
Run a QA in your experience
On a page where Demandbase is installed, paste the condition into the browser console and confirm it returns true for a visitor who should see the experience. Then follow the QA guide to check that the experience runs when it should and stays off when it should not.
Option 2: Fire the Location with the Manually trigger
You can also use the Manually trigger instead of the callback. A short script in your project's Global JS waits for the Demandbase data and then fires the Location, doing the same job as the callback. Manually and When a callback is called are both Dynamic Website Triggers, so they come with the same plans (check the Convert pricing page).
- Install the Demandbase tracking code before the Convert tracking code. Skip the wait helper and the callback code above.
- In the experience's Location settings, set the trigger to Manually and note the Location ID.
- In the Convert app, open your project and go to the Global JS section. Paste the script below, and replace
YOUR_LOCATION_IDwith the Location ID from the previous step. - Add the audience JS Condition shown above.
- Run a QA, and also test a first visit with an empty cache and a slow connection.
The script checks every 100 ms, up to 50 times (about 5 seconds), for the Demandbase company profile. When it appears, the script fires the Location.
(function () {
var tries = 0;
(function check() {
var p = window.Demandbase && Demandbase.Segments && Demandbase.Segments.CompanyProfile;
if (p) {
window._conv_q = window._conv_q || [];
window._conv_q.push({ what: 'triggerLocation', params: { locationId: 'YOUR_LOCATION_ID' } });
} else if (tries++ < 50) {
setTimeout(check, 100);
}
})();
})();
If Demandbase data does not appear within that window, the experience does not run for that visitor. Increase the 50 if your site loads Demandbase slowly. If your plan doesn't include Dynamic Website Triggers, use the legacy method instead.
Migrate from the legacy recheck token
If your experiences still use the old audience code with convert_recheck_experiment(), move the waiting logic out of the audience and into the Location:
- Add the
waitForDemandbasehelper to your Project Global JS. - Change the experience's Location trigger to When a callback is called and paste the callback code above.
- In the audience JS Condition, delete the
convert_recheck_experiment()branch and keep only the segment check. - Re-run a QA before publishing the change.
If your plan doesn't include Dynamic Website Triggers (legacy)
Without Dynamic Website Triggers, you can use the legacy convert_recheck_experiment() token in the audience condition instead. The token is being phased out. It still works today, but use the callback trigger above if your plan includes Dynamic Website Triggers.
When the condition calls the token, Convert checks the experience again every 50 ms for about 2 minutes, then stops. If the Demandbase data arrives after that, the experience does not run on that page view.
For a visitor Demandbase never identifies, the data never arrives, so the re-checks run for the full 2 minutes on every page view. Limit the experience's Locations to the pages where you need it.
- Install the Demandbase tracking code as described above. Skip the wait helper and the callback.
- Keep the Location trigger set to Upon Run.
- Add this JS Condition to the audience:
(function () {
var profile = window.Demandbase && Demandbase.Segments && Demandbase.Segments.CompanyProfile;
if (!profile) {
convert_recheck_experiment();
return false;
}
return profile.employee_range == "Small";
})()
Keep convert_recheck_experiment(); on its own line, as shown. The condition calls it only while the Demandbase company profile is missing. Once it exists, the condition returns true or false and the re-checks stop.
If your plan later includes Dynamic Website Triggers, follow Migrate from the legacy recheck token above.