Information for: DEVELOPERS   PARTNERS

Using Google Tag manager with Acquia Lift

When using Acquia Lift, you can use Google Tag Manager to instrument events, which can both provide more understanding, and a better customized experience for your users.

Video: Tracking custom events

The following video provides information about implementing custom events.

Creating a custom event capture with added variables

Using the following framework (with its own example values), you can build an Acquia Lift event with Google Tag Manager. Change any of the provided example names as appropriate for your application.

  1. Build an event used for tracking purposes. The following example uses an event labeled as Add to Cart.

    1. Create an event.
    2. Enter values in the following fields:
      • Event Name: Example value: Add to Cart
      • Event ID: Enter the machine name for the Event Name such as add_to_cart
      • Customer Site: Click Global
      • Event Type: Click Other
    3. Click Save to save the event.
  2. To map retrieved information to users, you must next Add column metadata for the event to Acquia Lift. Adding column metadata is an extra step only necessary if adding variables from the event to the profile.

    For the column metadata, use the following values:

    • Display Name: Product Name
    • Display Order: 1
    • Table: Event, for the Event table
    • Accessor: custom_field_1(getCustomField1) (ensure you note the number for the field)
    • Type: String
    • Description: Product name from Add to Cart
  3. Configure the Google Tag Manager to display the product name in the data layer of your website. Configure a variable in Google Tag Manager to store the product name: product-name. For an explanation of Google Tag Manager configuration, see Tags, triggers, variables, and the data layer.

    Google Tag Manager displaying the variable product-name

    After configuring the variable, create a trigger to fire when a user clicks the Add to Cart button.

    Google Tag Manager adding an add-to-cart trigger for form submissions

  4. Create a custom HTML tag to capture the Add to Cart trigger, using the Acquia Lift JavaScript API method of capturing a page view. To capture the Add to Cart trigger, use code as displayed in the following example:

    _tcaq.push(['capture', 'add_to_cart', { 'event_udf1':{{product-name}} }]);

    In the script, the event_udf1 must match the configuration in column metadata, corresponding to the table and the Accessor number, and Add to Cart must match the Event ID in Acquia Lift. If mapping to the touch or person table in column metadata, the code would reflect touch_udf1 or person_udf1 instead of event. After embedding the code, whenever a user clicks the Add to Cart button on a product page, an event will return in Acquia Lift as follows:

    Google Tag Manager displaying properties and values of an event in table format

    Other possible uses include creating triggers and events using the captureIdentity or updatePerson API functions.