Google Tag Manager and GTM Data Layer: GA4 ecommerce events for the shop
by Aerya IT Solutions https://aerya.net$ 43.83
Odoo 17, 18, 19 and 20, Community and Enterprise · Developed in the European Union by Aerya IT Solutions
Google Tag Manager and GTM Data Layer: GA4 ecommerce events for the shop
Add your Google Tag Manager container to every Odoo website and fill the data layer with the shop events of the GA4 e-commerce schema: product lists, product pages, cart, checkout, and one purchase per order. Consent Mode v2 is set before the container loads. The module only writes to the page in the visitor's browser and makes no call to Google.
purchase is sent once per order, never again on a reload
Consent Mode v2 default before the container, update on the visitor's choice
This module is a technical tool. The shop owner stays the controller: you sign the vendors' terms and you have the cookie banner text and the privacy policy checked by a lawyer. The screenshots use a fictitious furniture shop and invented customers.
Runs on Odoo.sh and on-premise, not on Odoo Online (SaaS), where Odoo does not allow modules with Python code. Please buy the version that matches your database.
The data layer of an order confirmation page. Screenshots of Odoo 19, valid for Odoo 20.
in Odoo 20, with browser tests that read window.dataLayer
no warnings
Community and Enterprise
What reaches the data layer
Events follow the GA4 e-commerce schema, so the standard GA4 tags and triggers of Tag Manager work with them.
| Event | When it is pushed |
|---|---|
| view_item_list | A shop page, a category or a search result |
| view_item | A product page |
| add_to_cart, remove_from_cart | The cart changes |
| view_cart | The cart page |
| begin_checkout | The checkout, once per cart |
| add_shipping_info, add_payment_info | The payment page |
| purchase | The confirmation page, once per order |
| sign_up, generate_lead | A new account, a submitted website form |
A container per website, in the website settings
Enter GTM-XXXXXXX on the website. The container script goes in the head and the noscript frame at the start of the body. A value that does not start with GTM- is refused when you save.
Leave out the internal users and the website editor, so your own clicks do not count as visits.

The GA4 e-commerce events, ready in the data layer
view_item_list and view_item on the shop pages; add_to_cart and remove_from_cart when the cart changes; view_cart, begin_checkout, add_shipping_info and add_payment_info through the checkout.
sign_up after a new account and generate_lead after a website form. Each event carries items with an id, name, price, quantity, category and variant.

The product page and the cart
The item id is the internal reference, or the variant id: your choice. Prices are sent with or without tax, as you set it, in the currency of the pricelist the visitor sees.
Adding and removing a product is seen on the cart as well as on a page that reloads after the change.

One purchase per order
The purchase event carries the order number, the value after discounts, tax, shipping, currency and the items. It is sent only for a confirmed order or one with a payment pending or done.
Odoo remembers which orders were sent, and the browser too, so a reload or a return to the confirmation page adds nothing.

Consent Mode v2 around the container
A consent default with every signal denied is written before the container script. When the visitor chooses, a consent update follows. The choice comes from the Aerya consent module if it is installed, otherwise from Odoo's cookie bar.

Screenshots of Odoo 19, valid for Odoo 20.
Next to Odoo's own Google setting
One container, counted once.
If the Google analytics key of the Odoo website settings is also set, the module does not load a second container and the settings page says so, so nothing is counted twice. Use it next to the Aerya cookie banner or Odoo's own cookie bar.
Everything included
One container per website
GTM-XXXXXXX in the website settings, checked on save.
GA4 e-commerce events
Lists, items, cart, checkout, purchase, sign-up and lead.
Purchase once
Kept in Odoo and in the browser: a reload sends nothing.
Tax and currency
Prices with or without tax, in the pricelist currency.
Item ids
The internal reference or the variant id.
Consent Mode v2
Default denied first, update on the visitor's choice.
Leave out staff
Internal users and the editor are not tracked.
Several websites
Every setting is per website.
How it works
Install the module and open Website, Configuration, Tag Manager.
Enter the container ID and choose tax, id and staff options.
Open the shop and read window.dataLayer in the browser.
Publish the container in Tag Manager with your GA4 tags.
Compatibility
| Versions | Odoo 17, 18, 19 and 20 |
| Editions | Community and Enterprise |
| Modules | Website; Website Sale for the shop events |
| Services | Google Tag Manager, GA4 e-commerce schema |
| Languages | English, German, French, Spanish, Dutch, Romanian |
What stops it, and what it does not do
Stops with a message: a container ID that does not start with GTM-. A purchase is not sent for an order with no confirmed or pending payment.
Not included: server-side tagging, sending events from the server, and per-variant events when the visitor changes an option on the product page. The module does not claim that a website complies with a law.
Explore our other apps
More modules by Aerya IT Solutions for Odoo 20, built to work together.
Questions or a custom quote?
Write to info@aerya.ro for questions about the module, its installation or custom development.
Developed in the European Union by Aerya IT Solutions, Odoo implementation and development. aerya.net
| Availability |
Odoo Online
Odoo.sh
On Premise
|
| Odoo Apps Dependencies |
•
Website (website)
• Discuss (mail) |
| Lines of code | 1043 |
| Technical Name |
aerya_website_gtm |
| License | OPL-1 |
| Website | https://aerya.net |
Odoo Proprietary License v1.0 This software and associated files (the "Software") may only be used (executed, modified, executed after modifications) if you have purchased a valid license from the authors, typically via Odoo Apps, or if you have received a written agreement from the authors of the Software (see the COPYRIGHT file). You may develop Odoo modules that use the Software as a library (typically by depending on it, importing it and using its resources), but without copying any source code or material from the Software. You may distribute those modules under the license of your choice, provided that this license is compatible with the terms of the Odoo Proprietary License (For example: LGPL, MIT, or proprietary licenses similar to this one). It is forbidden to publish, distribute, sublicense, or sell copies of the Software or modified copies of the Software. The above copyright notice and this permission notice must be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Please log in to comment on this module