GA4 for Ecommerce in Morocco: Track Real COD Sales
24 novembre 2026 · 9 min read
Lire en français · اقرأ بالعربية
In a Moroccan online store that sells mostly cash on delivery, GA4 counts placed orders by default, not collected revenue. To track real sales, send the purchase event when the order is confirmed, report cancellations and returns with the refund event, and tie every order to its GA4 client ID. Otherwise your reports overstate every campaign.
Key takeaways
- Morocco has 35.5 million internet users, or 92.2% of the population, according to DataReportal (Digital 2026).
- In 2025, online card payments reached 44.8 million transactions worth MAD 12.1 billion, against MAD 460 billion in cash withdrawals, according to Bank Al-Maghrib data.
- GA4 has a refund event linked to the order’s transaction_id: that is how you remove COD returns from your reports.
- The GA4 Measurement Protocol accepts events backdated by up to 72 hours.
- A standard GA4 property can mark up to 30 key events.
Why does GA4 overstate sales for a COD store in Morocco?
Because the purchase event usually fires on the thank-you page. At that moment, no money has changed hands. With cash on delivery, the order still has to be confirmed by phone or WhatsApp, shipped and accepted at the door. Each step loses part of the orders, as I explain in my guide to cutting COD returns in Morocco.
The Moroccan context widens the gap. Bank Al-Maghrib figures reported by Finances News Hebdo show online payments grew 16% in volume in 2025, to 44.8 million transactions and MAD 12.1 billion. Yet cash withdrawals reached MAD 460 billion over the year. Cash still dominates, and cash on delivery with it.
Take a hypothetical calculation, not a real case: 100 orders placed in a month, 70 confirmed by the call center, 55 delivered and paid. If GA4 records all 100 as sales, your measured revenue is more than 80% above what you actually collected. The ROAS shown for each channel is wrong by the same margin, and you may end up scaling the campaign that brings the most fake phone numbers.
Which GA4 events should a Moroccan online store set up?
Start from Google’s recommended ecommerce events, then move the trigger points to fit COD. The official GA4 ecommerce documentation lists view_item, add_to_cart, begin_checkout, add_shipping_info, add_payment_info, purchase and refund, among others. It states that transaction_id is required for purchases and refunds.
| Journey step | GA4 event | When to send it for COD |
|---|---|---|
| Product page viewed | view_item | When the product page loads |
| Added to cart | add_to_cart | On button click |
| Order form opened | begin_checkout | When the form opens (often a single page for COD) |
| Order placed | Custom event, for example cod_order | On the thank-you page, with the order number |
| Order confirmed | purchase | From your server, when the call center confirms the order |
| Card payment (CMI or other) | purchase | Directly on the thank-you page, since payment is done |
| Cancellation or return | refund | From your server, with the same transaction_id |
This split changes everything in your reports: the placed order measures intent, the confirmed order measures a likely sale, and the refund removes what was never collected.
How do you send confirmed orders and returns to GA4?
With the Measurement Protocol, the GA4 API that accepts events sent from a server. According to Google’s documentation, a request to a web stream requires an api_secret and the measurement_id, and the client_id must match the ID generated by the GA4 tag on your site. Here is the method I use:
- Capture the client_id at checkout. When the customer submits the form, I grab the browser’s GA4 ID and store it with the order, in the store backend or in the call center’s Google Sheet.
- Keep one unique order number. The same ID is used as transaction_id for the purchase and for any later refund.
- Fire the purchase on confirmation. When the status switches to “confirmed”, an n8n, Make or Zapier workflow sends the purchase event with the value in MAD, the currency and the items.
- Move fast. The Measurement Protocol accepts events backdated by up to 72 hours. Beyond that, under the default validation behavior, Google accepts them but resets their timestamp to 72 hours ago. Same-day confirmation keeps the data clean.
- Send a refund when delivery fails. Refused at the door, parcel returned or order cancelled after confirmation: the workflow sends a refund with the transaction_id and, ideally, the items involved to see returns by product.
- Check every week. I compare GA4 net revenue with the cash actually remitted by the courier. A growing gap means an event is getting lost.
If your call center already works on WhatsApp, the status change can come straight from your messaging stack, as I describe in my WhatsApp Business API guide for Morocco.
Which GA4 settings should you check first?
Before touching the tracking code, I check five settings. They take ten minutes and save months of unusable data.
| Setting | What I check | Why |
|---|---|---|
| Data retention | Switch from 2 to 14 months | According to Google Analytics Help, this setting limits explorations and funnel reports, not standard reports |
| Key events | Mark purchase and cod_order, not trivial clicks | A standard property allows up to 30; too many key events blur optimization |
| Currency | Send currency “MAD” with every purchase | A missing or wrong currency makes the value useless |
| Internal traffic | Exclude the team and the call center | Orders keyed in by phone distort sources |
| UTM tags | One naming convention for Meta, TikTok, WhatsApp and SMS | Without UTMs, a large share of sales lands in “direct” |
For UTMs, I use a builder shared with the whole team; you will find one among my free marketing tools.
Does GA4 replace the Meta or TikTok pixel?
No. GA4 is the neutral benchmark to compare channels with each other. Pixels and conversion APIs feed each ad platform’s algorithm. Both should receive the same truth: a confirmed sale, not a filled form. If you run TikTok campaigns, the same logic applies to the setup described in my TikTok Ads playbook for Morocco.
Once GA4 is fixed, cost per confirmed order becomes your real steering metric. It also tells you which traffic is worth paying for, including the visits now arriving from AI assistants, a topic I cover in measuring what AI search sends you.
Do you need consent to use GA4 in Morocco?
GA4 processes online identifiers, so Law 09-08 applies. The CNDP, created by that law of 18 February 2009, ensures that personal data processing is lawful. In practice, I recommend a clear privacy notice on the site, a cookie banner if you also target European visitors, and no personal data in clear text (name, phone) in the parameters sent to GA4. Rules on transfers abroad are covered in my article on AI and data protection under Law 09-08.
Frequently asked questions
Can GA4 track cash on delivery orders?
Yes, but not with the default setup. GA4 records what you send it. For a COD store, send a custom event when the order is placed, then the purchase event when the order is confirmed, from your server through the Measurement Protocol. Refusals and returns are reported with the refund event and the same transaction_id.
How do I record a COD return in GA4?
Send a refund event with the transaction_id of the original order. Google recommends adding the affected items with item_id and quantity so you can see returns by product. The simplest approach is to automate this call when the courier or call center moves the order to a returned status.
What is the GA4 Measurement Protocol?
It is the API that lets you send events to GA4 from a server instead of the browser. For a web stream, each request requires an api_secret and the measurement_id, and the client_id must match the one created by the site’s GA4 tag. Events can be backdated by up to 72 hours.
How long does GA4 keep data?
A standard property offers 2 or 14 months of retention for user-level and event-level data. The setting affects explorations and funnel reports, not standard aggregated reports. Set it to 14 months as soon as you create the property, because data already deleted under the shorter setting cannot be recovered.
How many key events can you create in GA4?
A standard GA4 property can mark up to 30 events as key events, and an Analytics 360 property up to 50. For a COD store, two or three are enough: order placed, order confirmed and, if you use it, the WhatsApp contact. Everything else can stay a regular event.
GA4 or Shopify analytics: which number should a COD store trust?
Neither, as long as returns are not removed. The reference figure is the cash actually remitted by the courier. GA4 becomes reliable once it receives confirmations and refunds: it then tells you which source, campaign and product generate sales that were really paid.
Summary
In Morocco, a store that measures orders instead of collected sales is steering its ads blind. The fix comes down to three moves: a separate event for the placed order, a purchase sent on confirmation, and a refund for every refusal or return. This measurement layer is what I set up before any optimization in my digital advertising work. If you want a second look at your current setup, get in touch.
Badreddine Cherradi — digital marketing consultant in Casablanca: performance marketing, SEO & GEO, AI and automation.
Updated on November 24, 2026.