OnyxMetric
Integration Guides

Odoo

Step-by-step guide to add OnyxMetric cookieless analytics to your Odoo website and start tracking visitors

The Odoo Website app has a Code Injection setting in the website editor's theme panel, with separate <head> and </body> fields that apply to every page of the website. The tag goes in the <head> field.

Copy your tracking snippet

In OnyxMetric, open your site's Site Settings and copy the tracking script. It looks like this:

<script src="https://app.onyxmetric.com/api/script.js?siteId=YOUR_SITE_ID" async></script>

YOUR_SITE_ID is the numeric ID of your site.

Add the snippet to Odoo

  1. Open your website's frontend and click Edit in the top bar.
  2. Switch to the Theme tab of the editor panel.
  3. Scroll to Advanced and, next to Code Injection, click <head>.
  4. Paste the snippet into the editor that opens and click Save.
  5. Click Save in the website editor to publish the change.

The code is stored per website. If you run several websites from one Odoo database, switch website in the top bar and repeat the steps for each.

Check that it works

Load your live site and click through a few pages. Pageviews show up in the OnyxMetric dashboard within seconds.

If nothing arrives:

  • View the page source and search for script.js?siteId= to confirm the tag is present.
  • In the browser's Network tab, check that script.js returns 200 and that requests go to /api/track.
  • Turn off ad blockers, or proxy the script through your own domain.
  • Read script troubleshooting for other causes.

Track custom events

Odoo eCommerce pages render standard HTML, so use data-onyx-event attributes on any element you add in the editor, or call window.onyx.event() from the </body> Code Injection field:

<script>
  document.addEventListener("click", function (e) {
    if (e.target.closest("#add_to_cart")) {
      window.onyx.event("add_to_cart");
    }
  });
</script>

The confirmation page is served at /shop/confirmation. A script that checks window.location.pathname there can send a purchase event once per order.

Troubleshooting

  • The <head> button is missing: Code Injection needs the Website → Editor and Designer access right. An administrator can grant it under Settings → Users & Companies → Users.
  • Visible while logged in but not to visitors: click Save in the editor after closing the code window, since the code is published with the page.
  • Multiple websites: the field applies only to the website currently selected in the editor.

Next steps

On this page