Products that cover the topic Magento 2 Google Analytics 4 (GA4) GTM Extension

Setting and verifying Google Analytics 4 Enhanced Conversions

 

One of the toughest tasks we had recently was to implement Google Analytics 4 Enhanced Conversions and moreover verify that it's actually working. There are a lot of tutorials and videos out there but almost none of them is providing real-world example how to implement and test.

I'm creating this quick article of all those poor souls like us that we banged our heads around for days untill we figure what is going on. So, let's get started. 

 

Prerequisites

In this article we shall review Google Analytics 4 conversion tracking and Enhanced Conversions support via pure gtag.js(), for those running Google Tag Manager, I shall prepare a spearate article. 

 

gtag() is installed via a snippet code which you can copy from your Google Ads Account, the only difference however is to enable allow_enhanced_conversions option as shown below. This ensures that any user_data and enhanced_conversion data would be automatically hashed() as per Google's requirements

{ } gtag.js() <script  async  src="https://www.googletagmanager.com/gtag/js?id=AW-000000000"></script> <script  nonce="d2J1cWM4ZnN3OGE1dzFtajFrbDh6N3ZxdWd5cmVpM3o=">         window.dataLayer  =  window.dataLayer  ||  [];         function  gtag(){  dataLayer.push(arguments);  }         gtag('js',  new  Date());         gtag('config',  'AW-000000000',{  allow_enhanced_conversions:  true,  send_page_view:  false  }); </script>

This code above is sufficient to install gtag() on success page and disable send_page_view to avoid duplicate pages (if you have GTM installed in parallel)

 

Google Ads Conversion Tracking (with Enhanced Conversions Support)

Now onto conversion tracking snippet. The snippet required for conversion tracking is shown below. As you can see we need to set pass user_data 

{ } gtag.js() gtag('set',  'user_data',   {         "email":  "developer@.....com",         "phone_number":  "+15555551234",         "address":           {                 "first_name":  "John",                 "last_name":  "Wick",                 "street":  "123  Main  St",                 "city":  "Los  Angeles",                 "region":  "CA",                 "postal_code":  "90001",                 "country":  "US"         } }); gtag('event',  "conversion",   {           "send_to":  "AW-16843397637/AbC-D_efG-h12_34-567",           "value":  243,           "currency":  "USD",           "transaction_id":           "000000024",           "new_customer":  false   });

This tells the gtag() api to send also user_data with the conversion request. There is no need to hash this data because allow_enhanced_conversions is seto Yes already.

 

Verifying Enhanced Conversions

Now onto verification. It is important as developer to verify that enhanced conversions are being set. To do so, use Chorme Developer Tools (F12 in Chrome), do not use Firefox, it won't show fetch() requests. 

When in Developer Tools, go to Network, then in the filter insert: googleadservices.com/pagead/conversion to filter out other requests and show only Google Ads Conversion requests. Then navigate to Payload and review the payload parmameters.

The most important one is: em  This is the hashed email, which is what Enhanced Conversions uses and inticates tha User Provided Data exists in the Conversion Request.

 

 

Another parameters indicating that Enhanced Conversion are working also include: 

ec_mode

This parameters indicates User Provided Data Collection Mode. It has 2 values

1. ec_mode 'c' indicates In Page code, this means that user_data has been explicitly provided in the page (in our case by using gtag('set','user_data',{}). This is the recommended way by Google for being more accurate and less prone to errors.

2. ec_mode 'a' indicates automatic user data collection


capi: 1 suggests that the Conversion API / server-side processing is enabled, which aligns with Enhanced Conversions

 

Extensions for Magento

Anowave is an extension developer for Magento 1.x and Magento 2.x platforms. We provide a wide range of premium extensions for our in-house and public clients. The extensions we offer extend the capabilities of Magento and provide bespoke functionality. They also fill some gaps in the functionality provided by the base platform and help customers choose Magento as their preferred eCommerce platform.

The extensions we offer are part of our full-range Magento service, which also includes a Premium Helpdesk where customers can speak with actual software engineers and have their issues resolved without hassle. Premium-labeled modules also include free installation, configuration, testing, etc.