Antlytics logoAntlytics

Add Antlytics to PrestaShop

Prerequisites

  • An Antlytics account (sign up free)
  • Your tracking ID from Settings → Tracking Snippet in your Antlytics dashboard

Install the snippet

The simplest way to add a global header script in PrestaShop is via a module:

  1. Install a header injection or custom HTML module from the PrestaShop Addons marketplace (search for "header script" or "custom code"). Several free options are available.
  2. In the module settings, paste the snippet into the Head or Header field so it is injected before </head> on every page.
  3. Save and clear your PrestaShop cache.

Alternatively, if you are comfortable editing theme files, open your active theme's header.tpl and paste the snippet just before the closing </head> tag.

Caching note: Always clear the PrestaShop cache after making theme or module changes.

<script>
(function(){
  var t="YOUR-SITE-ID",
      u="https://www.antlytics.com/api/ingest/pageview",
      k="ant_sid";
  function sid(){
    try{var s=sessionStorage.getItem(k);if(s)return s;
      s=crypto.randomUUID();sessionStorage.setItem(k,s);return s;}
    catch(e){return crypto.randomUUID();}
  }
  function utm(){
    try{var p=new URLSearchParams(location.search),o={};
      ["utm_source","utm_medium","utm_campaign","utm_term","utm_content"]
        .forEach(function(k){var v=p.get(k);if(v)o[k]=v;});
      return o;}
    catch(e){return {};}
  }
  function send(){
    fetch(u,{method:"POST",headers:{"Content-Type":"application/json"},
      keepalive:true,
      body:JSON.stringify(Object.assign(
        {tracking_id:t,pathname:location.pathname,
         referrer:document.referrer||undefined,session_id:sid()},
        utm()))});
  }
  send();
  window.addEventListener("popstate",send);
})();
</script>

Note: Replace YOUR-SITE-ID with the tracking ID from your Antlytics dashboard.

Verify installation

  1. Visit your site in a browser.
  2. Open your Antlytics dashboard → Overview.
  3. Your visit should appear within a few seconds.

If data does not appear after a few minutes, check the troubleshooting guide.

Optional: First-party proxy

To avoid ad blockers, set up a first-party proxy on your own domain.

Need help?

Email support@antlytics.com with your site ID and page URL.

Something missing? Get in touch and we will update these docs.