cs-icon.svg

Event Tracking (Lytics) in Contentstack Launch

Event Tracking (Lytics) is an Experience Customer Data Platform (xCDP) that helps businesses deliver personalized digital experiences by unifying customer data from multiple sources. It builds real-time, behavior-based audience segments, enabling marketers and developers to target users more effectively across channels such as web, email, and advertising platforms.

Prerequisites

Steps for Execution

  1. Connect Contentstack Organization to an Event Tracking (Lytics) Organization
  2. Connect Launch Project with DAL
  3. Enable Event Tracking for Your Launch Environment
  4. Disable Event Tracking for Your Launch Environment
  1. Connect Contentstack Organization to an Event Tracking (Lytics) Organization

    Follow the steps below to create a connection between your Contenstack organization and an Event Tracking (Lytics) organization:

    1. Log in to your Contentstack account, and click the Org Admin icon in the left navigation panel.
    2. Under Settings, click Data Activation Layer.
    3. Click the + New DAL Configuration button.
  2. Connect Launch Project with DAL

    Follow the steps below to create a connection between your Contenstack organization and an Event Tracking (Lytics) organization:

    1. Log in to your Contentstack account, and click the Org Admin icon in the left navigation panel.
    2. Under Settings, click Data Activation Layer.
    3. Click the + Add DAL Configuration button.
    4. In the modal that appears, enter the following details:
      • Title: Enter a suitable name for your DAL.
      • Domain: Enter the domain name corresponding to a Real-Time Event Tag.
      • CMS Stacks: (Optional) Add your CMS stack if you’ve set it up for this specific Launch project or website.
      • Launch Projects: Select the Launch project where you want to integrate Event Tracking (Lytics).
      • Personalize Projects: (Optional) Add your Personalize project if you’ve set it up for this specific Launch project or website.
      • Lytics Account: Create a Lytics account if one does not already exist, and connect the appropriate Lytics account to your DAL.

        Note: Ideally, each DAL should be connected to a single website for optimal tracking and data consistency.

    5. Click the Save button.
  3. Enable Event Tracking for Your Launch Environment

    Follow the steps below to enable Event Tracking in your Launch environment:

    1. Go to your Launch dashboard and click the project card to open your project from the Launch landing page.
    2. On the Environments screen, click the vertical ellipses under Actions next to your environment and then click Settings. Launch_Lytics_Settings.png
    3. In the Settings page, go to Environments > Event Tracking.
    4. Click the Enable Event Tracking toggle to enable Event Tracking for Launch. Launch_Lytics_EnableToggle.png
    5. In the modal that appears, click the checkbox to accept the privacy regulations and then click the Yes, Enable Event Tracking button to confirm the action. Launch_Lytics_EnableLytics.png

      Accepting the consent modal will load the Event Tracking script to your website.

    6. Update your site to include a consent modal. Use a Consent Management Platform or build your own modal to collect this consent.
    7. Perform a mandatory redeployment once you have enabled Event Tracking on the environment.

    Note: Although Event Tracking will now be enabled for your site, user events will not be tracked until the end user "opts in" to sharing their data with you. To test the Event Tracking data collection feature prior to building a consent modal, open the browser console and enter the command jstag.optIn(). This will enable data collection for Event Tracking for that specific session. This won’t allow Event Tracking data collection across all the user sessions.

    Caching Behaviors

    • If your application uses browser-side caching, redeploy your site after enabling or disabling Event Tracking to prevent browsers from serving outdated scripts due to ETag-based caching.
    • Without a redeploy, users might see a cached version that does not reflect the updated script.

    Verify the Enabled Event Tracking

    • After enabling, you should see a <script> tag for Event Tracking injected into your website’s HTML responses. Launch_Lytics_Script.png
    • You can also install the browser extension for debugging.
  4. Disable Event Tracking for Your Launch Environment

    Important: Ensure to remove the code jstag.optIn() in your consent modal. This is so that you don’t face any runtime issues due to the Event Tracking script tag missing.

    Follow the steps below to deactivate Event Tracking in your Launch environment:

    1. Go to your Launch dashboard and click the project card to open your project from the Launch landing page.
    2. On the Environments screen, click the vertical ellipses under Actions next to your environment and then click Settings. Launch_Lytics_Settings.png
    3. In the Settings page, go to Environments > Event Tracking.
    4. Click the Enable Event Tracking toggle again to disable Event Tracking from your Launch project. Launch_Lytics_DisableToggle.png
    5. In the modal that appears, click the Yes, Disable Event Tracking button to confirm the action. Launch_Lytics_DisableLytics.png
    6. Perform a mandatory redeployment to remove the Real-Time Event Tag due to browser-side caching.

    Once disabled:

    • The Event Tracking <script> tag will no longer be injected into your website’s HTML.
    • All Event Tracking-based audience personalization will cease.
    • The environment will display the following message:
      “Event Tracking is not enabled for this project. Please contact your organization admin to enable it.”

Handling User Consent - optIn()

  1. When Event Tracking is enabled, a Real-Time Event Tag will be injected into your website's <head> tag.
  2. Implement a consent modal or use a custom tag to trigger in your Google Tag Manager Account.
    Learn more about obtaining user consent via the consent modal or Google Tag Manager.
  3. When the user consents to share cookies, call jstag.optIn(). This will start Real-Time User Event Tracking for the user session.

Handling User Consent Rejection - optOut()

  • If the user denies permission for cookie consent, call jstag.optOut() to stop Real-Time User Event Tracking for the user sessions.
Was this article helpful?
^