Information for: DEVELOPERS   PARTNERS

capture - Acquia Lift JavaScript API

Although Acquia Lift 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:

Metatags

Acquia Lift determines the page context to use when tracking captures and segmenting users. Acquia Lift 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. Acquia Lift 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 Acquia Lift JavaScript 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.

Note

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.

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']);
</script>

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

Note

You will generally want to capture the page view for every tracked webpage, you can add the instruction to the end of the Acquia Lift 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

Acquia Lift 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 Acquia Lift, create an event in Profile Manager.

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

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

where [event_id] is the ID of the event you created.

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 Acquia Lift-enabled Drupal website. These can be set in the Acquia Lift settings by going to Configuration > Web Services > Acquia Lift, in the Data collection settings section.