Setting Up a Custom Store
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.
1. On the Google Tag Manager Overview page, select New Tag
2. Name your Tag
3. Click Tag Configuration and select Custom HTML
4. Paste the following snippet of code into the HTML box. You will be provided a BrandID to replace the highlighted value 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>
5. Set the Triggering section of the Tag Configuration page to All Pages
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.
Required Fields
• firstName (mandatory)
• email (mandatory)
• All other fields are strongly encouraged for personalization
ltvai.track.push({
profile: {
firstName: "John",
lastName: "Doe",
email: "john.doe@example.com",
phoneNumber: "+18589191204",
city: "New York",
zipCode: "10001",
stateCode: "NY",
countryCode: "US",
timeZone: "America/New_York",
locale: "en_US"
}
});
Phone number should be in E.164 format. Time zones should be in IANA Time Zones format.
Push Purchase Event Data to LTV.ai
Once a profile is initialized and is valid, the script opens up to event tracking. The order placed event is one of the key events we track.
Required Fields
• orderId (mandatory)
• totalAmount (mandatory)
• All other fields 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-01T00: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-01T00:00:00.000Z"
});
Common Examples
• addToCart
• viewItem
• viewCategory
How it Works
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 solved 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.
Troubleshooting
• Verify correct profile info and brand ID
• Check network connectivity
• Ensure you are allowing requests to https://scripts.ltv.ai and https://data.ltv.ai
Contact Us - If troubleshooting internally does not resolve your issues, please reach out to us for direct support.
