GA4 eCommerce Tracking - Google Analytics 4 Enhanced eCommerce, GA4 Measurement Protocol, Google Consent Mode v2
by Modvanta https://modvantaapps.tech/odoo-apps/ga4-tracking/$ 29.91
Google Analytics 4 eCommerce tracking for Odoo - every shop event, every purchase once, refunds from the server, Consent Mode v2
The storefront sends GA4 enhanced ecommerce events with full items, the purchase is reported once per order, purchases the browser missed and refunds from credit notes go through the GA4 Measurement Protocol, and the Odoo cookies bar drives Google Consent Mode v2.
Written and supported by Modvanta - modvantaapps@gmail.com
What it does
The module uses the Google Analytics key of your Odoo website as the GA4 measurement ID and sends the GA4 ecommerce events from the shop: view_item_list, select_item, search, view_item, add_to_cart, remove_from_cart, add_to_wishlist, view_cart, begin_checkout, add_shipping_info, add_payment_info and purchase, plus login, sign_up and generate_lead. Items carry id, name, variant, category, price, discount and quantity.
With an API secret the server can send the purchase through the GA4 Measurement Protocol when the customer's browser did not report it (ad blocker, closed tab), always, or instead of the browser, using the same transaction_id so nothing is counted twice. Credit notes and order cancellations can be sent as refund events. Every server event is logged with its request, HTTP status and answer, can be checked against the GA4 validation server and sent again.
Google Consent Mode v2 follows the Odoo cookies bar: basic or advanced mode, the default state of ad_storage, ad_user_data, ad_personalization and analytics_storage, regional defaults, wait_for_update, url_passthrough and ads_data_redaction. A debug mode adds debug_mode for GA4 DebugView, writes events to the browser console and shows them in a panel on the page.
Who it is for
Odoo eCommerce shops Get GA4 ecommerce reports with real item data instead of page views only. | Stores losing purchases to ad blockers Let the server report the purchases the browser did not send, once per order. | Shops selling in the EU Respect the visitor's cookie choice with Google Consent Mode v2 on the Odoo cookies bar. |
Key features
Every screen below is the module running on Odoo 19. The server events went to a local stand-in for Google (placeholder measurement ID and API secret), which answers like the real collection server.
Feature 1
One GA4 setup per website
Measurement ID, Measurement Protocol API secret, server container URL, the Odoo cookies bar, item id and brand attribute, who is tracked (no internal users, no known bots, user ID, user properties, debug mode) and when the purchase is reported. Test Server Connection sends a test event to the GA4 validation server.
Feature 2
Consent Mode v2
Basic mode (Google tag only after consent) or advanced mode (tag at once, cookieless pings until consent), the default state before the visitor answers, what the Agree button grants, regional defaults, wait_for_update, url_passthrough and ads_data_redaction.
Feature 3
Server events with the Measurement Protocol
Purchase by the server: browser only, server when the browser did not report it, browser and server with the same transaction_id, or server only, with the wait time. Refunds from credit notes and on order cancellation, consent requirement, collection endpoint (global or EU), send attempts and how long events are logged.
Feature 4
view_item and the consent banner
On a product page the view_item event is sent with the full item; the debug panel shows the measurement ID, consent state, consent mode and every event, while the Odoo cookies bar asks for consent.
Feature 5
add_to_cart with items
Adding to the cart sends add_to_cart with currency, value and the item, after the visitor accepted cookies.
Feature 6
view_cart
The cart page sends view_cart with all cart lines.
Feature 7
Server events log
Every server purchase and refund with transaction id, value, currency, consent, state, send time, HTTP status and answer. An order without a cookie choice is logged as not sent with the reason.
Feature 8
The request that was sent
Each event keeps the exact Measurement Protocol request with client_id, transaction_id, value, tax, shipping and items, the HTTP status and Google's answer; Validate with Google posts it to the validation server.
How it works, step by step
| 1 | Install and enter the measurement ID Put your GA4 measurement ID (G-...) as the website's Google Analytics key and switch GA4 eCommerce Tracking on. |
| 2 | Add an API secret for server events Create a Measurement Protocol API secret in GA4 Admin and paste it; Test Server Connection sends a test event to the validation server. |
| 3 | Set consent Enable the Odoo cookies bar and pick basic or advanced Consent Mode v2 and the default states. |
| 4 | Check with the debug panel Turn on debug mode and open the shop with ?ga4_debug=1 to see every event on the page and in GA4 DebugView. |
| 5 | Let orders and refunds flow Confirmed website orders report the purchase once; credit notes send refunds; follow both in the events log. |
Settings
Settings are per website, under the website's GA4 Tracking form and in the Website settings.
| Google Analytics 4 | Enable tracking, measurement ID, API secret, server container URL, Odoo cookies bar. |
| Events and items | Values with or without taxes, item_id from internal reference or product ID, brand attribute, events not to send. |
| Who is tracked | No tracking for internal users or known bots, send user ID, user properties, debug mode. |
| Purchase | When the purchase is reported (order confirmed), late purchases window, browser and server modes, wait for the browser. |
| Consent Mode v2 | Basic or advanced, default and granted states for the four consent types, regional defaults, wait_for_update, url_passthrough, ads_data_redaction. |
| Delivery and privacy | Server events need consent, collection endpoint, send attempts, event log and retention. |
Frequently asked questions
Do I need Google Tag Manager?
No. The module loads the Google tag itself from your measurement ID. If another module already loads it, the tag is shared.
Will purchases be counted twice?
No. The purchase is sent once per order; when both browser and server send it they use the same transaction_id, and the server skips orders the browser already reported unless you choose otherwise.
What does the API secret do?
It lets the server send purchases and refunds through the GA4 Measurement Protocol, so ad blockers and closed tabs do not lose orders.
Does it respect cookie consent?
Yes. Consent Mode v2 follows the Odoo cookies bar, and server events can be limited to orders whose customer accepted cookies.
How do I check that events arrive?
Turn on debug mode: events show in GA4 DebugView, in the browser console and in a panel on the page with ?ga4_debug=1. Server events can be validated with Google from the log.
Compatibility
Odoo 19 Community and Enterprise | eCommerce website_sale | Google Analytics 4 gtag and Measurement Protocol | Consent Google Consent Mode v2 |
Track your Odoo shop in GA4 the right way
Questions before you buy, help with setup, or a change for your own workflow - write to us and a developer answers.
SUPPORT | AUTHOR Modvanta | INCLUDED Module, debug panel, email support |
| Availability |
Odoo Online
Odoo.sh
On Premise
|
| Odoo Apps Dependencies |
•
eCommerce (website_sale)
• Website (website) • Discuss (mail) • Invoicing (account) |
| Lines of code | 2462 |
| Technical Name |
mdv_ga4_tracking |
| License | OPL-1 |
| Website | https://modvantaapps.tech/odoo-apps/ga4-tracking/ |
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