No results found

Try a different search query

Popular searches:

Add to Cart

Cart

You have no purchases yet

Browse Marketplace
Original Subtotal:
Product discounts:
Quantity Discount:
Total:
View Cart
Advertising and analytics

GA4 in OpenCart: How to Set Up E-commerce Tracking in 3.0 and 4.1

How to send product views, cart, checkout and purchase data from OpenCart to Google Analytics 4: what the 3.0 and 4.1 core includes, which events are needed, and how to verify the data.

8 min read OC 3.0 OC 4.1

To make GA4 in OpenCart show not only visits but also sales, you need to send e-commerce events: product view, add to cart, start of checkout, and purchase with the order total and contents. The OpenCart core does not do this in either 3.0 or 4.1, so the events are added with a module or through Google Tag ManagerA container for managing scripts without editing code. More in the glossary →. Below are the events you need, where to get their data in OpenCart, and how to make sure the data is correct.

What does e-commerce give you in GA4, and why isn't the tag enough?

A regular Google AnalyticsA system for analyzing visitor behavior. It is connected with code or in "Extensions → Extensions," type "Analytics." More in the glossary → tag on the pages counts sessions, traffic sources, and page views. That is enough to know how many people came from Instagram or search, but not enough to answer the main question for a store: which sources bring orders and money. For that, GA4 has a separate set of "Monetization" reports, which are filled only when the site sends e-commerce events.

When events are configured, you see revenue by each channel and campaign, best-selling products, the funnel from product view to purchase, average order valueRevenue divided by the number of orders. More in the glossary →, and the share of returning customers. The same data is imported into Google Ads as conversions with value, so ads start optimizing for sales rather than clicks. For what to set up before GA4, see the article store analytics on the first day.

Pay attention to the difference between OpenCart versions.

  • OpenCart 3.0: there is a standard Google Analytics extension ("Extensions → Extensions", type "Analytics"). It simply outputs the code you insert into the header of every page and knows nothing about products or orders.
  • OpenCart 4.1: the "Analytics" extension type exists, but a ready-made Google Analytics extension is not included.

So in both versions, the standard tools only give you a basic tag, and e-commerce has to be added separately.

OpenCart 3.0: розширення типу «Аналітика», куди вставляється код тегу Google Analytics
OpenCart 3.0: the "Analytics" extension where the Google Analytics tag code is inserted · OpenCart 3.0.5.1

Which e-commerce events does an OpenCart store need?

GA4 has standard event names for e-commerce. Use exactly these, not invented names: then reports and the import into Google Ads will work without additional setup.

GA4 eventWhere it occurs in OpenCartPriority
purchaseSuccessful order confirmation pageRequired
add_to_cart"Buy" button on the product card and in listsRequired
begin_checkoutTransition to the checkout pageRequired
view_itemProduct pageRecommended
view_item_listCategory, search, product modules on the home pageRecommended
view_cart, remove_from_cartShopping cartRecommended
add_shipping_info, add_payment_infoChoosing shipping and payment at checkoutAs needed

Every event with products passes the items array: product identifier (SKU or product_id), name, price, quantity, and ideally the manufacturer and category. For a purchase, you also need the order number transaction_id, the total value, and the currency currency — for a Ukrainian store that is UAH. The order number is mandatory: GA4 uses it to reject a repeated event with the same number.

Decide in advance what counts as the product identifier. If you plan to advertise through Google Merchant CenterA Google service where the product feed for Shopping ads is uploaded. It requires correct prices, availability, and identifiers. More in the glossary →, the identifier in the events must match the identifier in the product feed, otherwise remarketing for specific products will not find matches.

Where in OpenCart do you get the data for events?

The hardest part of e-commerce for OpenCart is not the tag code, but the correct data at the right moment. There are several peculiarities of the core that you need to account for.

Adding to cart works through AJAX

The "Buy" button does not reload the page: in OpenCart 3.0 it calls the checkout/cart/add route, in OpenCart 4.1 the checkout/cart.add route. Therefore add_to_cart must be sent from JavaScript after a successful server response, not on click: if the product was not added (a required option was not selected, out of stock), the event must not be sent.

The success page clears order data

On the successful order page (route checkout/success), OpenCart in both 3.0 and 4.1 removes the order number and checkout data from the session. The default template of this page does not receive the order number, total, or products. The analytics module must save the order data earlier or insert it into the page before it is cleared — this is exactly where homemade solutions most often break.

Online payment can bypass the success page

A customer paying by card goes to the payment service page and does not always return to the site. Then the purchase event on the success page will not fire, even though the order has been paid. The solution is to send the purchase from the server via the GA4 Measurement Protocol at the moment the order receives its status, or at least to compare the number of purchases in GA4 and in the admin panel. If the status does not change after payment either, see the article payment went through, but the status did not change.

A module or Google Tag Manager?

There are two working ways to add e-commerce to OpenCart. The first is a ready-made module that generates events itself from OpenCart data. The second is Google Tag Manager: the site puts product and order data into the dataLayer data layer, and the GA4, Google Ads, and pixel tags are configured in the GTM interface. However, someone still has to write the data layer in OpenCart templates, so GTM does not eliminate the developer's work; it only moves tag settings from code to the interface.

Here is what a purchase event looks like in the data layer, so you know what should appear on the success page:

window.dataLayer = window.dataLayer || [];
dataLayer.push({ ecommerce: null });
dataLayer.push({
  event: 'purchase',
  ecommerce: {
    transaction_id: '1052',
    value: 2450.00,
    currency: 'UAH',
    shipping: 80.00,
    items: [
      { item_id: 'SKU-118', item_name: 'Чайник електричний', price: 1185.00, quantity: 2 }
    ]
  }
});

For OpenCart 3.0, a complete ready-made solution is the SP SEO Remarketing All In One Pro module: it sends enhanced e-commerce to GA4 and, in parallel, events for Google Ads, Meta Pixel with Conversions API, TikTok, and other systems, so you don't have to stitch several scripts together. How it is configured is described in detail in the review GA4, Facebook CAPI and TikTok in OpenCart. For OpenCart 4.1, choose a module whose 4.1 compatibility is explicitly stated in the description, or GTM with a data layer.

Also think about cookie consent: if the banner simply blocks GA4 until consent is given, some purchases will disappear from the reports. How to do this correctly will be covered in the Consent Mode section article.

How do you check that GA4 counts correctly?

Run the check right after setup and after every update of the theme or checkout modules: those are the most common causes of broken events.

  1. Enable debug mode in GA4 (DebugView) or the Tag Assistant extension, and go through the buyer's path: category → product → cart → checkout → purchase.
  2. Make sure each event arrives once and has a products array with price and quantity.
  3. Place test orders with each payment and shipping methodAn extension that calculates the cost: "Extensions → Extensions," type "Shipping." More in the glossary →, including online payment and returning from the bank's website.
  4. Check the total: whether shipping is included in value, and whether the coupon is accounted for. The main thing is one consistent rule for all orders.
  5. Refresh the success page: a repeated purchase should not appear.
  6. After a week, compare the number of purchases and the revenue in GA4 with the sales report under "Reports → Reports" in the admin panel.
Звіти OpenCart: звіт продажів для звірки з покупками в GA4
OpenCart reports: the sales report for reconciling purchases with GA4 · OpenCart 4.1.0.4

A small discrepancy (roughly up to 10–15%) is normal due to ad blockers and cookie refusals, and depends on your audience. However, if GA4 shows twice as many or twice as few purchases as the admin panel, look for duplicates or lost online payments. Delete the test orders afterward or mark them with a separate status so they don't distort the reports.

If you want to see traffic, GA4 revenue, and advertising directly on the OpenCart 3.0 admin dashboard, there is the Store Analytics Dashboard widget. It does not replace event setup; it only shows their results.

Summary

  • The standard GA4 tag counts visits, and sales appear only with e-commerce events.
  • OpenCart 3.0 has a basic Google Analytics extension only for inserting code; OpenCart 4.1 does not have one. E-commerce in both versions requires a module or GTM with a data layer.
  • Minimum set: purchase with the order number, total, currency UAH, and products; add_to_cart after a successful AJAX response; begin_checkout.
  • Keep in mind that the success page clears order data, and online payment may bypass it entirely.
  • One source of events, test orders for each payment method, and regular reconciliation with the admin panel.

Other advertising and analytics settings — pixels, remarketing, UTM — are collected in the section Advertising and Analytics.

FAQ

Can I import old OpenCart orders into GA4?
No, GA4 does not accept historical data retroactively. E-commerce reports will only start filling in from the day the events are set up.
What should I put in item_id: SKU or product ID?
Use the same value as in your product feed for Google Merchant Center. The key thing is that the value matches in both the feed and the events.
Should I send cancelled orders to GA4?
There is a refund event for this. If cancellations are frequent, it is worth setting it up, otherwise revenue in GA4 will be overstated compared with actual figures.
Do I need a separate Google Ads tag if GA4 is already set up?
Conversions can be imported from GA4, but for remarketing with dynamic ads and more accurate tracking, a separate Google Ads tag is often added as well.
Was this article helpful?
Thanks for your feedback!

Related articles

Didn't find the answer?

Ask the community: OpenCart developers answer on the forum.

Ask on the forum
We use cookies

We use cookies and similar technologies to improve your experience, analyse traffic, and show personalised ads. Read our Cookie Policy for details.