capture - Personalization JavaScript API

Although Personalization can capture visitors’ webpage views on their own, there are also other methods which can capture data. Each of the following methods can make use of additional variables to capture more specific information:


Personalization determines the page context to use when tracking captures, capturing language, and segmenting users. Personalization can collect further custom page information using the Capture API. Visitor profile custom fields are user-defined fields used to capture information specific to a customer website. Personalization passes the custom values along with capture data when specified within <meta> tags in the <head> section of a page or when specified in the global PersonalizationJavaScript scope. To pass capture data or user-defined fields using a metatag, the metatag should be added to the <head> in the following format:

<meta itemprop="acquia_lift:custom-field-name" content="custom-field-value">

From the preceding format, custom-field-name is the parameter used by captureView, which is the field name used by the data warehouse. The custom-field-value parameter is the value to track for that field. The custom field name uses the format acquia_lift:[TABLE]_udf[NUMBER], where:

  • [TABLE] is either person, touch, or event.

  • [NUMBER] is the custom field selected when creating the custom column metadata.

For example, if person_udf50 represents Industry, and the current visitor’s industry is the healthcare industry, then the metatag for the page capture will be the following:

<meta itemprop="acquia_lift:person_udf50" content="Healthcare">

To pass the same information directly using JavaScript, use the following code:

window.AcquiaLift = window.AcquiaLift || {};
window.AcquiaLift.profile = window.AcquiaLift.profile || {};
window.AcquiaLift.profile.person_udf50 = 'Healthcare';

If the same field is defined in both a metatag and within JavaScript, the value defined within JavaScript will be used.


Metatags must be defined in the page before the lift.js reference on the initial page load. If the tags are defined after the JavaScript is called, the script will not work properly because updates will be reflected only in the next script call.

To capture the language context for a page or user in the current Drupal version, use the following metatag:

acquia lift: context_language

JavaScript variables

You can also define variables directly in your page’s JavaScript, like the following:

window.AcquiaLift.profile.person_udf5 = 'my dynamic content goes here';

The default timeout set in both lift.js and the /decide-js endpoint is 30 seconds. You can alter the timeout value for all calls (except authentication calls) by providing a different timeout value. For example, the following code increases the timeout value to 60 seconds:

window.AcquiaLift.loadTimeout = 60;

Tracking scripts

You can perform various actions using tracking scripts to capture more information about your Page Views.

Capturing a page view

To capture a page view, add the following JavaScript code to your webpage:

<script type="text/javascript">
_tcaq.push(['capture', 'Content View']);

Personalization captures the page view and associates it with the website visitor’s information.


You will generally want to capture the page view for every tracked webpage, you can add the instruction to the end of the Personalization tracker script.

Capturing additional page view information

The capture method includes several parameters which you can use to include additional information about the webpage or the website visitor:

_tcaq.push(['capture', '<category>', {'<parameter>':'<value>'}]);

Capturing do_not_track information

Personalization provides the ability to set do_not_track information for a user. The capture API (POST call) allows the user to send a capture while indicating whether or not the visitor should be tracked. The capture must use the following event_name: updatePersonTracking. For example:

"identity": "qa_5373_2016-12-01 13:21:[email protected]",
"identity_source": "email",
"do_not_track": true,
"return_segments": true,
"captures": [
      "event_source": "app",
      "event_name": "updatePersonTracking",
      "event_date": "2016-11-24 13:21:57.418",
      "engagement_score": 0

Passing custom events through the JavaScript API

To use custom events with Personalization, create an event in Personalization.

You can then pass the event to the Personalization service by using the following JavaScript command:

<script type="text/javascript">
_tcaq.push(['capture', 'event_id']);

where event_id is the ID of the event you created.


Public _tcaq functions are only available after lift-capture.js is loaded on a page after personalization return. You will know lift-capture.js hasn’t loaded on a page if you receive the following reference error:

ReferenceError: _tcaq is not defined

Drupal taxonomy mappings

You can use Drupal taxonomy terms in your page capture by ensuring you have mapping fields set to taxonomy vocabularies in your Personalization-enabled Drupal website. These can be set in the Personalization settings by going to Configuration > Web Services > Personalization, in the Data collection settings section.