Settings · 8 min read
Tracking Sources
Collect page views, screens and actions from your websites and apps to build contact profiles, trigger journeys and measure ROI
Tracking Sources (Settings → Tracking Sources in the sidebar) collect what people do on your website and in your apps: page views, app screens, and actions such as adding to cart or placing an order. Use them to see what your contacts do, build segments from it, start journeys when someone does something, and give journeys and campaigns their revenue and ROI.
A source is self-serve: create it, add the snippet or SDK with its write key, and events start arriving.
Websites and apps#
Each source is one of two kinds:
| Kind | For | How you install it |
|---|---|---|
| Website | Any website, including React and Next.js sites | Paste the snippet into your site, or use the JavaScript or React package |
| App | iOS, Android, Flutter and React Native apps | Add the Lemu SDK for your platform. See SDKs |
One app source can serve the same app on every platform, for example your Android and iOS builds. Create a separate source for each website, or for each environment such as staging, so their events stay apart.
Events from every source use the same names. Lemu uses Meta Pixel's standard events (PageView, ViewContent, AddToCart, Purchase and the rest), so the same event means the same thing on your site, in your app and in your Shopify store. See Standard and conversion events.
Add a source#
Choose the kind
Under Add a tracking source, choose Website or App.
Name it
Give it a Name, for example "Main store" or "Android and iOS app".
Restrict where events come from
For a website, list the Allowed sites. For an app, list the Allowed apps. You can also leave this empty now and fill it in on the source later (see below). Then click Create.
Install it
Open the new source. Under Set up, copy the write key and follow the steps for your platform.
Allowed sites#
For a website source, Allowed sites lists the sites allowed to send events with its write key, one per line. Use an exact site such as https://shop.example.com, or https://*.example.com for every subdomain. Click Save sites after changing the list on a source.
Events from any other site are refused. Leave the list empty only while testing.
Allowed apps#
For an app source, Allowed apps lists the bundle ids or package names allowed to send with its write key, one per line, for example com.brand.app. Click Save apps after changing the list on a source.
Every event must name an allowed app, so a key copied into another app doesn't work by accident. Leave the list empty to accept any app.
Set up#
Each source shows its write key (it starts with lpk_) and setup steps for each platform, with the key already filled in. The write key is the same for every platform of the source. It is public by design and safe to put in your site or app: it can only send events, never read anything.
| Source | Setup tabs |
|---|---|
| Website | Any website (the snippet) and React / Next.js |
| App | Android, iOS, Flutter and React Native |
Each tab shows how to install, how to set up with your key, and how to send events, including a purchase.
The website snippet#
Paste the snippet into the <head> of every page. It loads the Lemu script and records a page view. It looks like this, with your own write key:
<script>
!function(w,d){w.lemu=w.lemu||function(){(w.lemu.q=w.lemu.q||[]).push(arguments)};
var s=d.createElement("script");s.async=1;s.src="https://app.lemuai.com/api/v1/pixel/sdk.js";
d.head.appendChild(s)}(window,document);
lemu("init", "YOUR_WRITE_KEY");
lemu("page");
</script>Copy the snippet from your source rather than from this page, so the key and address are right.
For JavaScript, React and Next.js sites and for apps, see the SDKs.
Track actions#
Call track when someone does something you care about. Use Meta's standard event names where one fits:
lemu("track", "AddToCart", { value: 999, currency: "INR", content_ids: ["SKU1"] });
lemu("track", "Lead", { content_name: "Newsletter" });
lemu("track", "Signed Up for Newsletter");Report orders with purchase. It sends a Purchase event straight away, so it isn't lost if the visitor closes the thank-you page:
lemu("purchase", { value: 1499.5, currency: "INR", order_id: "1042" });How names are stored:
- A Meta standard event is stored with Meta's spelling, whatever the case or separators:
add_to_cart,Add To Cartandaddtocartare all stored asAddToCart. - Any other name is a custom event and is stored in lowercase with underscores, so "Signed Up for Newsletter" is stored as
signed_up_for_newsletter. Use that spelling in journeys and segments.
Page views are stored as PageView and app screens as screen_viewed.
Identify visitors#
Visitors are anonymous until they identify. Call identify when someone logs in, signs up or fills a form:
lemu("identify", { email: "asha@example.com", phone: "+919876543210", first_name: "Asha" });
lemu("identify", "crm-123", { email: "asha@example.com" }); // your own id first
lemu("reset"); // on logout: start a new anonymous visitor- An
identifywith an email or a phone finds the matching contact, or creates one taggedwebsite. - An
identifywith only your own id links the visitor to an existing contact with that id. It never creates a contact. - Anonymous visitors are not contacts and don't count toward your plan's contact limit.
- Once a visitor identifies, their earlier anonymous visits show up in the contact's activity.
The SDKs work the same way.
Trigger journeys#
Switch on Let identified visitors' tracked actions trigger journeys on the source. Then track events from identified visitors work like events from the API: they appear on the contact and can start any journey whose Events trigger matches the event name. Page views, screens and actions from anonymous visitors never start journeys.
A purchase from an identified visitor counts toward revenue and ROI even when this switch is off. The switch only controls whether actions start journeys.
Website options#
Pass options as the third argument to init:
lemu("init", "YOUR_WRITE_KEY", { trackPageChanges: true, cookieDomain: ".example.com" });| Option | What it does |
|---|---|
trackPageChanges | Records a page view on every in-app navigation. Use it for single-page apps |
cookieDomain | Shares the visitor id across subdomains, for example .example.com |
requireConsent | Collects nothing until consent is given (see below) |
debug | Logs every call, request and response to the browser console |
apiHost | Where to send events. Defaults to where the script was loaded from |
UTM parameters (utm_source, utm_medium, utm_campaign, utm_term, utm_content) and gclid / fbclid on the landing page are kept with the visitor's events, along with the referrer. So is lmclid, which Lemu adds to message links to your own sites: a visitor who arrives with it, and isn't known yet, is linked to the contact the message went to. See Link Click Tracking.
Consent and opt-out#
If you need consent before tracking, for example after your cookie banner, start with requireConsent:
lemu("init", "YOUR_WRITE_KEY", { requireConsent: true });
lemu("consent", true); // from your consent banner, once the visitor agreesUntil consent, nothing is sent and nothing is written to cookies or local storage, not even the visitor id. Up to 50 events wait in memory and are sent once consent is given. lemu("consent", false) discards them.
To switch tracking off for a visitor, call lemu("optOut"). It is remembered in the browser. lemu("optIn") turns it back on.
The app SDKs have the same consent and opt-out calls.
Privacy#
- Personal data stays out of events. Keys such as
email,phone,mobile,whatsapp,password,otp,card,card_number,cvv,pan,aadhaarandaddressare dropped from event and page properties. Send contact details only throughidentify. - No advertising ids. The website script and the app SDKs collect no advertising ids (IDFA, GAID) and no hardware ids. Each browser or app install gets a random visitor id instead.
- Bots are filtered out on websites.
Limits and duplicates#
- Website sources: up to 120 batches a minute from one visitor IP address.
- App sources: up to 120 batches a minute from one device. Apps are not limited by IP address, because mobile networks put many people behind one address.
- Batch size: each batch holds up to 100 events and 256 KB. The script and SDKs batch events for you.
- Duplicates: the same event sent twice within 24 hours is recorded once, so retries are safe.
- Late events: an event dated more than 7 days ago, or in the future, is recorded at the time it arrives.
Manage a source#
| Action | What it does |
|---|---|
| Collecting switch | Turn it off to pause the source. A paused source shows Paused and its events are refused |
| New write key | Makes a new key. The current key stops working within a minute, so update your site or app first |
| Delete | Removes the source. Its snippet or SDK key stops working |
The source card also shows when the last event arrived, or "No events received yet.", so you can confirm the setup works. Events from your sources also appear in the Event Log under the Website source.
Recent events#
Each source has a Recent events debugger. Click Show recent events to see the last 50 events the source received in the past hour, as Lemu stored them, then Refresh to load new ones.
- Each event shows its name, the time and the platform it came from.
- Click an event to see its properties (after personal data was removed) and context, such as the app version, device and campaign.
- Events that count as orders are marked Conversion. If one was missing a value, a currency or an order id, it shows how many issues it had and what Lemu did, for example "no order_id: the same order sent twice counts twice". See Standard and conversion events.
Contact details from identify are never shown here. Turn on debug mode in the script or SDK to see each request from your side as well.
Shopify stores#
If your Shopify store is connected, its source is created for you and shows storefront events from your store instead of a snippet. The pixel code lives on Integrations → Shopify → Storefront events: paste it once into Shopify's Customer Events as a custom pixel.
Shopify's standard events are recorded under these names:
| Shopify event | Lemu event |
|---|---|
| page_viewed | PageView |
| product_viewed | ViewContent |
| collection_viewed | viewed_collection |
| search_submitted | Search |
| product_added_to_cart | AddToCart |
| product_removed_from_cart | removed_from_cart |
| cart_viewed | viewed_cart |
| checkout_started | InitiateCheckout |
| checkout_address_info_submitted | checkout_address_submitted |
| checkout_shipping_info_submitted | checkout_shipping_submitted |
| payment_info_submitted | AddPaymentInfo |
| checkout_completed | Purchase |
Events with a Meta equivalent use Meta's name and parameters (value, currency, contents, content_ids, and order_id on purchases). The others keep their Lemu names. Older journeys and segments that use the previous names, such as viewed_product or checkout_completed, still match. See Old names that still match.
When a shopper enters their email or phone at checkout, or is logged in, they are identified automatically.
Next steps#
Was this page helpful?
Docs