Other platforms
Add Loogika to Odoo
You add Loogika to an Odoo website through the Code Injection setting in the Theme tab of the website editor. Paste the script tag into the <head> field, and Odoo adds it to every page of that website. You can use the method with Odoo 17 and 18, whether the install runs on Odoo Online, on Odoo.sh or on-premise.
Last updated .
What do you need before you start?
Copy your script tag from Site Settings in Loogika, under the Tracking Script tab. It looks like this, with your own 12-character site ID in place of YOUR_SITE_ID:
<script src="https://app.loogika.com/api/script.js?siteId=YOUR_SITE_ID" defer></script>
Your Odoo user needs the access right Editor and Designer for the Website app. Without it, Odoo does not show the Code Injection buttons.
How do you add the Loogika tag in Odoo?
- Open the frontend of your website. In the top bar, click Edit.
- The editor panel has a Theme tab. Switch to it.
- Scroll to the Advanced section. Next to Code Injection, click
<head>. - A code editor opens. Paste the script tag into it and click Save.
- Publish the change with Save in the website editor.
What if you run several websites in one Odoo database?
Odoo stores injected code per website, so one paste covers one website only. Pick another website in the top bar and go through the steps again, once for every site you want to track.
How do you track add-to-cart clicks in Odoo eCommerce?
Call window.loogika.event() from the </body> field of Code Injection. This script listens for clicks on the element with the ID add_to_cart and sends an event for each click:
<script>
document.addEventListener("click", function (e) {
if (e.target.closest("#add_to_cart")) {
window.loogika?.event("add_to_cart");
}
});
</script>
Odoo eCommerce pages are standard HTML. You can therefore also put data-loogika-event on any element that you add in the editor. The events page shows how that attribute works.
How do you track a purchase in Odoo?
Odoo serves the order confirmation page at /shop/confirmation. A script in the </body> field can check window.location.pathname for that path. When the path matches, the script sends a purchase event with window.loogika.event().
How do you check that Loogika is installed?
Load your website in a fresh browser tab and visit a few pages. The pageviews show up in the Loogika dashboard within a few seconds. If nothing arrives, open the page source and look for script.js?siteId=.
Why does Odoo not send data to Loogika?
| Problem | Cause and fix |
|---|---|
The <head> button is missing | Your user lacks the Editor and Designer access right for Website. An administrator grants it under Settings, then Users & Companies, then Users, on the Access Rights tab of the user |
| You see the tag while logged in, and visitors do not | The code is published together with the page. Click Save in the website editor after you close the code window |
| One of several websites reports no data | The field applies only to the website that is selected in the editor. Repeat the steps for the missing website |