Skip to content

Integration Documents

  • There are no suggestions because the search field is empty.

Setting up a Custom Store

This section provides everything you need to know to connect your custom store with LTV.ai.

What you will need:

Install Tracking Script

The LTV.ai tracking script can be placed either directly in the head of your website pages or via Google Tag Manager. The following instructions assume a Google Tag Manager implementation.

Step 1. On the Google Tag Manager Overview page, select New Tag

Step 2. Name your Tag 

Step 3. Click Tag Configuration and select Custom HTML

Step 4. Paste the following snippet of code into the HTML box. You will be provided a BrandID to replace the highlighted value at in your snippet by your contact at LTV.ai during onboarding.

<script>!function(l,t,v,a,i){l[a]=l[a]||{track:[]};var n=t.getElementsByTagName(v)[0],s=t.createElement(v);s.defer=!0,s.src="https://scripts.ltv.ai/track.js?id="+i,n.parentNode.insertBefore(s,n)}(window,document,"script","ltvai","BrandID");</script>

Step 5. Set the Triggering section of the Tag Configuration page to All Pages

Step 6. Click Save

Push Profile Data to LTV.ai

To ensure personalized user interactions, tracking a user profile is mandatory. Use the following method to push user profile information as the very first push to the script. From the following attributes, firstName and email are mandatory but the rest are strongly encouraged for personalization.

Some rules for formatting are provided as inline comments:

ltvai.track.push({
    profile: {
        firstName: "John",
        lastName: "Doe",
        email: "john.doe@example.com",
        /* Phone number should be in E.164 format */
        phoneNumber: "+18589191204",
        city: "New York",
        zipCode: "10001",
        stateCode: "NY",
        countryCode: "US",
        /* Time zones should bein IANA Time Zones format */
        timeZone: "America/New_York",
        locale: "en_US"
    }
});

Push Purchase Event Data to LTV.ai

Once a profile is initialized and is valid, the script opens up to event tracking. You can track events using an event similar to the following shape

Order Placed: The order placed event is one of the key events we track. We recognize the following attributes by default. Please note that the orderId, totalAmount are mandatory fields but the rest are strongly encouraged for personalization.

ltvai.track.push({
    metric: "orderPlaced",
    payload: {
        orderId: "12345",
        totalAmount: 350.00,
        items: [{
            itemId: "001",
            sku: "SKU1234",
            name: "Product Name",
            category: "Category",
            quantity: 1,
            price: 100.00
        }],
        couponCodesUsed: ["SPRING2021"],
        paymentMethod: "Credit Card",
        currency: "USD",
        discountAmount: 50.00
    },
    at: "2023-01-001T00:00:00.000Z"
});

 
Push Custom Event Data to LTV.ai

All other events can be pushed with your own defined metric and event schema.

ltvai.track.push({
    metric: "yourMetricName",
    payload: {
        // Your event-specific data here
    },
    at: "2023-01-001T00:00:00.000Z"
});

Some common examples are:

  • addtoCart
  • viewItem
  • viewCategory
  • Profile Identification: The profile identification tags a user's browser with a permanent profile id.
  • Event Funnel: We use the above profile id and the brand id to funnel events provided by you to our servers.
  • Race Conditions: Race conditions are solve by modeling the push call as an array and maintaining any events in an array queue until the tracking script initializes. Any event pushes, prior to the profile push, will be dropped