Install web tracking
The Contlo tracking snippet is one script tag. Once it is on your pages, Contlo can recognize returning visitors, record the pages and products they view, show your forms and web push prompts, and accept the identify and event calls you make from your own code. That activity is what your segments and automations use to turn visitors into first orders and repeat purchases.
Les guides sont en anglais.
Do you need to install it yourself?
| Your store | What to do |
|---|---|
| Shopify | Nothing. The snippet is added when you connect the store. See Shopify. |
| WooCommerce | Nothing. The Contlo plugin adds it. See WooCommerce. |
| Custom site or any other platform | Install the snippet yourself, as described on this page. |
The snippet uses your Public API Key. Public keys are safe to expose in page source. Never put a private API key in front-end code.
Get your snippet
- Open the account menu in the top bar and choose Settings.
- In Organization, find the Connect your custom store card and click Show snippet code. The card appears only for accounts that are set up as a custom store.
- On the Unique snippet code page, click Copy.
The snippet already contains your public key. It looks like this:
<script type='text/javascript' async='' src='https://marketing.contlo.com/js/contlo_messaging_v3.js?v=3&shop_id=YOUR_PUBLIC_API_KEY'></script>Install on a custom site
Paste the snippet in the <head> of every page you want Contlo to track. Most sites do this once, in the shared layout or header template. The script loads asynchronously, so it does not block the page.
Through Google Tag Manager
You can publish the same snippet as a Custom HTML tag in Google Tag Manager, firing on all pages. Contlo's install check understands this setup: if it does not find the snippet in your page HTML, it looks inside the Google Tag Manager containers that the page loads (up to three).
In a JavaScript app, with npm
If you prefer to load the script from your application code, the contlo-web-sdk package does it for you. It checks your key and site URL, then injects the same script tag into the page.
npm i contlo-web-sdkVerify the installation
- Publish the change to your live site.
- Go back to the Unique snippet code page in Contlo.
- Under Enter your URL to verify the connection., type your site address in Store URL (the
https://is already filled in) and click Verify. - When the check passes, click Connect now.
| Message | What it means |
|---|---|
| Snippet is installed on URL … | Contlo found your snippet in the page HTML. |
| Snippet is installed on URL … via Google Tag Manager | Contlo found your snippet inside a Google Tag Manager container on the page. |
| Snippet is not installed on URL … | The page loaded, but no snippet with your public key was found. Check that the change is published, that the key in the snippet is yours, and that the URL you entered is a page that includes the snippet. |
| Invalid URL, please enter a valid one! | Contlo could not load the address. Check for typos and make sure the page is publicly reachable without a login. |
You can also check from the browser. Open your site, open the developer console and run the line below. Both values should be object.
typeof window.contlo, typeof window.contloWebSDKWhat the snippet does automatically
| Behavior | Details |
|---|---|
| Recognizes visitors | Each browser gets an anonymous visitor ID. The visitor becomes a known contact when they submit a Contlo form, arrive through a link that carries their Contlo contact ID, or when your code identifies them. See Track events and identify visitors. |
| Page views | For recognized visitors, page loads are recorded as Viewed Page (view_page). The same page viewed again by the same contact within an hour is not recorded twice. |
| Product views | For recognized visitors, a page whose URL contains /products/ followed by a product handle from your catalog is recorded as Viewed Product (view_product_page), with the product, its collections, price and any UTM parameters on the URL. |
| Visit history | First visit time, last visit time and number of visits are kept in the browser and used for form targeting. |
| UTM parameters | utm_source, utm_medium and utm_campaign from the landing URL are remembered for one day and used for form targeting. |
| Cart contents | On storefronts that expose the standard Shopify cart endpoints (/cart.js, /cart/add, /cart/update, /cart/change), the cart is synced to Contlo whenever it changes. |
| Forms, web push and chat | The snippet displays the popups, embedded forms, web push opt-in prompt and chat widget you have switched on in Contlo. See Forms and Push settings. |
Hosts to allow
If your site uses a Content Security Policy or a firewall allowlist, allow these hosts.
| Host | Used for |
|---|---|
marketing.contlo.com | The script itself, page views, cart sync and visitor recognition. |
events.contlo.com | Identify and event calls made through window.contloWebSDK. |
form-ext.contlo.com | Loading and displaying your forms. |
callback-service.contlo.com | The chat widget, if you use it. |
cdnjs.cloudflare.com | A small encryption library the script loads. |
Troubleshooting
| Symptom | What to check |
|---|---|
| Show snippet code is missing | The card is shown only for custom stores. Shopify and WooCommerce accounts get the snippet automatically. If you run a custom site and do not see it, write to hello@contlo.com. |
| Verification fails but the snippet is on the page | The check reads the page from Contlo's servers. Pages behind a login, a password screen or a bot filter cannot be read. Verify against a public page. The key in the snippet must match your public key exactly. |
window.contlo is undefined | The script did not load. Look for a blocked request to marketing.contlo.com in the network tab, usually caused by an ad blocker or a Content Security Policy. |
| No page views for a test visitor | Page views are recorded only after the visitor is recognized. Identify yourself first, then reload the page. |
| Product views are missing | The URL must contain /products/ followed by the handle of a product that exists in your Contlo catalog. A repeat view of the same product by the same contact within four hours is not recorded again. |
Event calls return 403 with Enter valid url | Calls through window.contloWebSDK are accepted only from sites where the snippet has loaded. Make sure the snippet runs on the same origin before you send events. |
Guides associés
- Track events and identify visitorsUse the Contlo browser methods to tell Contlo who a visitor is and what they did, then use those events in segments, automations and analytics.
- REST APISend contacts and events to Contlo from your server: authentication, the identify and track endpoints, request and response examples, limits and errors.
- API keys, webhooks and callback URLsFind your public API key, create and revoke private API keys, and learn where webhooks and callback URLs live in Contlo.
- ShopifyConnect your Shopify store to Contlo: permissions, what is synced and when, storefront tracking, Shopify events and discounts, and disconnecting.
- WooCommerceConnect a WooCommerce store to Contlo with the Contlo plugin: what is synced, how storefront tracking works, and how to fix a connection.