Skip to main content

Conversion Tracking Setup Guide

In this guide: Learn how to enable conversion tracking for touchpoints, install the Li2 Analytics SDK, and prepare your system to track lead and sale events.

Prerequisites

Plan Requirement: Conversion tracking is only available for:
  • Premium Plan and above
  • Premium Trial (for testing)
If you’re on the Free or Basic plan, please upgrade to use this feature.
Before you begin, ensure you have:

Access Rights

Owner or Manager role in your organization

Touchpoint Created

At least one touchpoint to track conversions

Website/App Access

Ability to add JavaScript code to your web pages

Premium+ Plan

Premium plan or higher

Setup Process Overview

The conversion tracking setup consists of 4 main steps:
1

Enable Conversion Tracking for Touchpoint

Activate tracking in touchpoint settings
2

Install Li2 Analytics SDK

Add tracking code to your website/app
3

Configure Security

Set up allowed hostnames to protect your data
4

Verify Setup

Test and confirm tracking works correctly

Step 1: Enable Conversion Tracking for Touchpoint

1.1 Access Touchpoint Settings

1

Open Touchpoint Details

In your dashboard, navigate to Touch-Points and select the touchpoint you want to track conversions for.
2

Go to Settings Tab

Click the Settings tab (⚙️ icon) in the touchpoint details page.
3

Find Conversion Tracking Section

Scroll down to Advanced Settings → locate Conversion Tracking.

1.2 Activate Conversion Tracking

In the Conversion Tracking section:
  1. Toggle the switch to ON (green)
  2. Click Save Changes to apply
Best Practice: Only enable conversion tracking for touchpoints that genuinely need ROI measurement (e.g., main campaigns, important landing pages). This keeps your data clean and easy to analyze.
Enabling conversion tracking doesn’t affect your touchpoint’s current functionality. Short links, QR codes, and NFC tags continue to work normally. Tracking only begins once you integrate the SDK (Step 2).

Step 2: Install Li2 Analytics SDK

The Li2 Analytics SDK is a JavaScript library that automatically tracks conversions. There are 2 installation methods:

Installation for Regular HTML Websites

Add this script to the <head> or before </body> of all pages that need tracking:
<script>
  !(function (c, n) {
    c[n] = c[n] || function () {
      (c[n].q = c[n].q || []).push(arguments);
    };
    ["trackLead", "trackSale"].forEach(
      (t) => (c[n][t] = (...a) => c[n](t, ...a))
    );
    var s = document.createElement("script");
    s.defer = 1;
    s.src = "https://unpkg.com/@li2/analytics/dist/index.global.js";
    s.setAttribute("data-publishable-key", "li2_pk_xxxxxxxx");
    document.head.appendChild(s);
  })(window, "li2Analytics");
</script>
Replace publishableKey:
  • Find the line: s.setAttribute("data-publishable-key", "li2_pk_xxxxxxxx");
  • Replace li2_pk_xxxxxxxx with your actual publishable key from Settings → Analytics
Script placement:
  • In <head>: Loads early, ensures tracking always works
  • Before </body>: Doesn’t block page render, but might miss early events
Recommendation: Place in <head> with defer attribute (already included in script) to balance performance and tracking accuracy.

Step 3: Configure Security

3.1 Set Up Allowed Hostnames

Allowed Hostnames is a list of domains permitted to send tracking requests. This is a critical security layer to prevent abuse.
1

Open Analytics Settings

Navigate to Settings → Analytics in your organization settings.
2

Add Allowed Hostnames

In the Security section, find Allowed Hostnames and add your domains:Examples:
  • example.com - Only allows exact domain
  • *.example.com - Allows all subdomains (www, app, blog, etc.)
  • localhost - Allows local development (recommended for dev)
3

Save Changes

Click Save to apply the whitelist.
Important: If you don’t add allowed hostnames, tracking requests will be BLOCKED. Make sure to add all domains and subdomains you use.
Wildcard Support:
PatternAllows
example.comOnly example.com
www.example.comOnly www.example.com
*.example.comapp.example.com, blog.example.com, etc.
*All domains (NOT recommended for production)
Development Setup: When developing locally, add localhost or 127.0.0.1 to allowed hostnames. Remove when deploying to production.

3.2 Review Publishable Key

The publishable key is automatically generated when you enable Analytics. To view:
  1. Go to Settings → Analytics
  2. Copy Publishable Key (format: li2_pk_...)
  3. Paste into SDK configuration (already done in Step 2)
Publishable vs Secret Key:
  • Publishable key (li2_pk_...): Safe to expose client-side, used for SDK
  • Secret key (li2_sk_...): Server-side only, DO NOT expose to clients
Conversion tracking SDK only needs the publishable key.

Step 4: Verify Setup

4.1 Test Click ID Capture

After installing the SDK, test whether click IDs are being captured correctly:
1

Create Test Link

From the touchpoint with conversion tracking enabled, copy the short link (e.g., li2.link/test-campaign)
2

Click Link in Incognito Mode

Open your browser in incognito mode and click the short link
3

Check Cookie

Open Developer Tools (F12) → ApplicationCookiesLook for a cookie named li_cid with a value like: cm3w...Success if cookie existsFailed if no cookie → Recheck SDK installation
4

Verify in Console

In the Console tab, type:
li2Analytics
If the SDK loaded correctly, you’ll see an object with functions: trackLead, trackSale
Causes:
  1. Script hasn’t finished loading: Wait for page to fully load and try again
  2. CDN blocked: Check Network tab to see if request to unpkg.com is blocked
  3. Ad blocker: Disable ad blocker and test again
Fix: Check script tag in HTML source, verify CDN is accessible, disable ad blockers
Cause:
  • Current domain not in Allowed Hostnames
Fix:
  1. Go to Settings → Analytics → Allowed Hostnames
  2. Add current domain (e.g., example.com)
  3. Save and test again
CORS error messages are usually very clear: Request origin 'https://example.com' is not included in the allowed hostnames. Copy the exact domain and add it to the allowed list.

4.2 Test End-to-End Flow (Optional)

To test the complete flow from click → lead tracking:
// Open Console after clicking touchpoint link
li2Analytics.trackLead({
  eventName: "Test Lead",
  customerExternalId: "test-user-123",
  customerEmail: "[email protected]",
  customerName: "Test User"
});
Check Network tab - you should see a POST request to API endpoint with status 200 OK.
Note: This test lead will be actually recorded in the database. Li2 currently does not support deleting conversion events via UI. Recommendations:
  • Use eventName: "Test ..." to easily distinguish from real data
  • Or test on development/staging environment before deploying to production

Complete! 🎉

You’ve successfully set up conversion tracking! Next steps:

Troubleshooting

Cause: Organization doesn’t have Premium plan.Fix:
  1. Go to Settings → Billing
  2. Upgrade to Premium or higher
  3. Or start Premium Trial to test
Solutions:
  • SDK is already optimized with defer loading - doesn’t block page render
  • Global CDN distribution ensures low latency
  • Minified bundle size < 10KB
If still concerned: Load SDK async after page interactive:
window.addEventListener('load', function() {
  // Inject SDK script here
});
Li2 Analytics SDK currently only supports web tracking (JavaScript).For mobile apps: Use Server-side tracking with API keys. See Events Tracking - Server-side.
In Touch-Points list, look for 📊 icon next to touchpoint name. This icon only appears when conversion tracking is enabled.Or filter touchpoints with Advanced Filters → Conversion Tracking = Enabled.

Best Practices

1. Enable tracking selectively: Only enable for important touchpoints to keep data clean and easy to analyze.2. Test in development: Always add localhost to allowed hostnames when developing, remove when deploying to production.3. Monitor setup: Check Analytics dashboard regularly during the first week after setup to catch issues early.4. Document your setup: Record where publishable key and allowed hostnames are stored so other team members can maintain.5. Secure your keys: Publishable keys are safe for clients, but NEVER commit secret keys to Git.