The Special Formula To Setting Up GA4 Ecommerce

Before we proceed, I would like to include a disclaimer that this solution may not be applicable to all accounts and its functionality depends on the structure of your dataLayer. If your dataLayer conforms to the GA3 guidelines, then this solution is likely to work effectively.

I would also like to give a shoutout to Simo Ahava for developing a template that fulfils a critical requirement by transforming GA3 dataLayer items into a format that can be easily read and understood by GA4.


Check out the steps below.

1. Navigate to the Variables tab and select “New” option under the User-Defined variables section.


setting up ga4 ecommerce step 1


2. Access the variable configuration and select “Discover more variable types” in the Community Template Gallery. Next, search for “GA4” and locate the EEC Products -> GA4 Items template created by Simo Ahava.


setting up ga4 ecommerce step 2


Once you have located the EEC Products -> GA4 Items template, add it to your workspace and save it. Ensure that you don’t make any alterations to the template and save it as “EEC Products -> GA4 Items”.


setting up ga4 ecommerce step 3


3. Generate variables for Items, Transaction ID, Value, Tax, Shipping, Currency, and Coupon. To accomplish this, click on “New Variable” and search for “DataLayer variable”. Please note that the codes used for these variables will differ depending on the structure of your dataLayer. In most of my e-commerce accounts, I have utilised “” or “ecommerce.value” with successful outcomes.


setting up ga4 ecommerce step 4


4. The code for “items” may remain the same as before, which is “ecommerce.items”, or it could be slightly different, depending on your dataLayer structure. If this applies to you, raise a custom JacaScript for:

function() {

var ecom = {{Ecommerce}};

if ( ecom && ecom.items ) {

return ecom.items;

} else {

return undefined;




5. It’s possible to create a single tag for all events, which will resemble the following format:


setting up ga4 ecommerce step 5


6. Your trigger will be a customised event, and you can create a single trigger for all events.

Event Name:

view_item | view_item_list | select_item | add_to_cart | remove_from_cart | view_cart | begin_checkout | add_payment_info | add_shipping_info | purchase

These are the steps to raise GA4 eCommerce events. It is crucial to understand that this method may not be compatible with all eCommerce platforms. You must have a purchase event or add_shipping event in the dataLayer for this method to function. We have had success with this approach in approximately 80% of our accounts.

Looking for professional assistance with your PPC campaigns? Our team has a wealth of experience collaborating with diverse clients, assisting brands of all sizes in achieving their annual sales, leads, and revenue targets via data-backed campaigns. Book a complimentary consultation to explore how we can help you achieve comparable results.

Absolute Insights in Your Inbox: Sign-up to our newsletter and get more insights delivered straight to you. Stay informed with up-to-date industry news, and more from the A-Team!

    Get A Quote

      • Service
      • Budget
      • Info
      Please provide us with your contact details. so we can fulfil your enquiry.
      SEOPPCDigital PRLink BuildingOther (Marketplaces, Paid social...) £1,000 - £5,000£5,000 - £10,000£10,000 - £20,000£20,000+ We are currently using an agencyLooking for an agency ImmediatelyWithin 1-2 monthsWithin 3-6 monthsIn 6+ months time

      Subscribe me to the latest digital marketing updates and promotional information