Google Tag Manager Integration
In this guide: Learn how to implement Li2 conversion tracking using Google Tag Manager - no code changes required.
Google Tag Manager
Google Tag Manager (GTM) is the most popular way to implement Li2 conversion tracking without touching your website’s code. This method is ideal for marketers who want control over tracking without depending on developers.Prerequisites
Before you begin, ensure you have:GTM Container
GTM script installed on your website
Conversion Tracking Enabled
Enabled in touchpoint settings (see Setup Guide)
Publishable Key
Available in Settings → Analytics
GTM Edit Access
Permission to create tags and variables
GTM Setup: Install Li2 SDK
Step 1: Create Custom HTML Tag
Open GTM Container
Log in to Google Tag Manager and select your container
Step 2: Create Click ID Variable
This variable reads theli_cid cookie set by Li2 when users click your touchpoint links.
Configure Variable
- Variable Type: 1st Party Cookie
- Cookie Name:
li_cid - Variable Name: “Li2 Click ID”
GTM Lead Tracking
Track when users sign up, register, or show interest in your product/service.Option 1: Thank You Page Tracking (Recommended)
When to use: You redirect users to a thank you page after form submission (e.g.,/thank-you, /success, /welcome)
Script:
Option 2: Form Submission Tracking
When to use: You want to track immediately when the form is submitted (no redirect)
Script:
GTM Sale Tracking
Track revenue when customers make purchases.Option 1: Order Confirmation Page (Recommended)
When to use: You redirect users to an order confirmation page after successful payment (e.g.,/order-confirmation, /checkout/success)
Script:
Amount Format: Amount must be in smallest currency unit (cents for USD, đồng for VND):
- ✅ CORRECT:
amount: 4999= $49.99 - ❌ WRONG:
amount: 49.99= $0.49
Option 2: E-commerce Data Layer Tracking
When to use: Your site pushes e-commerce data to GTM’s data layer (common for Shopify, WooCommerce, Magento)
Script:
Testing Your GTM Setup
Step 1: Use GTM Preview Mode
Connect to Website
Enter your website URL and click Connect. A new window opens with GTM debugger overlay
Test SDK Loader Tag
- Navigate through your site
- In GTM debugger, verify “Li2 Analytics - SDK Loader” fires on all pages
- Check Tags Fired section
Test Lead Tracking
- Navigate to form page or thank you page
- Verify lead tracking tag fires
- Check tag configuration and variable values in debugger
Step 2: Browser Console Verification
Open browser console (F12) and verify: 1. SDK Loaded:Step 3: Network Tab Verification
- Open DevTools → Network tab
- Filter by “track” or your API domain
- Trigger lead/sale events
- Look for POST requests to Li2 API endpoints
- Check request payload to ensure correct data is sent
Troubleshooting
Tag not firing in GTM Preview
Tag not firing in GTM Preview
Common causes:
- Trigger conditions don’t match: Check that page URL or form selector matches exactly
- Tag sequence issue: Ensure SDK loader tag fires before tracking tags
- Variable not returning value: Test
{{Li2 Click ID}}in GTM Variables section
- Use GTM debugger to see why trigger didn’t match
- Test trigger conditions manually (check actual URL, form ID in inspector)
- Verify variable is configured correctly (cookie name =
li_cid)
li2Analytics is not defined
li2Analytics is not defined
Cause: SDK loader tag hasn’t fired or script failed to loadFix:
- Check GTM Preview - did “Li2 Analytics - SDK Loader” fire?
- Check Network tab - is script loading from unpkg.com?
- Ad blocker blocking? Disable and test again
- Check browser console for JavaScript errors
- Verify publishable key is correct (no typos)
li_cid cookie not set
li_cid cookie not set
Form fields returning empty values
Form fields returning empty values
Cause: DOM selectors don’t match your actual form structureFix:
- Inspect your form HTML to find actual field IDs/classes
- Update selectors in the script:
- Test in browser console first to verify selector works
Sale amount is wrong (showing $0.49 instead of $49.99)
Sale amount is wrong (showing $0.49 instead of $49.99)
Cause: Amount not converted to centsFix:
Events tracked multiple times (duplicates)
Events tracked multiple times (duplicates)
Cause: Tag firing multiple times due to incorrect trigger setupFix:
- Check GTM debugger - how many times did tag fire?
- Review trigger conditions - is it too broad?
- For form submissions: Enable “Wait for Tags” and set max wait time
- For page views: Ensure URL condition is specific enough
- Use
invoiceIdparameter to prevent duplicate sales (Li2 deduplicates within 7 days)
CORS errors in console
CORS errors in console
Cause: Current domain not in allowed hostnames listFix:
- Go to Li2 Settings → Analytics → Security
- Add your domain to Allowed Hostnames:
- For exact match:
example.com - For all subdomains:
*.example.com - For development:
localhostor127.0.0.1
- For exact match:
- Save and test again
Best Practices
Coming Soon
Shopify Integration
Native Shopify app for automatic conversion tracking
WooCommerce Plugin
WordPress plugin for WooCommerce stores
Zapier Integration
Connect Li2 to 5,000+ apps via Zapier
Segment Integration
Send conversion events through Segment CDP
Want early access? Contact us at [email protected] to join our beta program for upcoming integrations.

