Google Ads enables the analysis of product and customer data (subject to appropriate permissions) and facilitates more effective campaign optimization, especially for e-commerce websites. These processes can be carried out either through modified methods within the GTAG method or directly via GTM.
Following the article titled “Global Site Tag (gtag.js) Event Handling”, let’s proceed with conversion (tracking) tags. However, in this article, I will detail the conversion process using cart data. First, let’s briefly recap the scope of the conversion process.
Conversion
A conversion refers to a valuable action or process performed by customers (including defined target audiences for potential customers). Examples include e-commerce transactions (transaction), lead generation (lead), video viewing, and similar actions, all of which can be classified as conversion events.
Refer to my earlier article titled “Google Analytics Goals and Funnel Actions” for Universal Analytics (UA) implementation details.
Conversion tracking allows us to understand what happens after customers interact with the ads you’ve launched (linked to specific ad campaigns), such as whether they purchased a product, signed up for an email newsletter, made an inquiry about your business, or downloaded an app.
How Conversion Tracking Works
The conversion tracking process begins with defining a specific conversion and then applying the appropriate tag to that definition. The relevant actions can be performed across various channels, including website interactions1,, phone calls, app installations, and in-app actions2, offline data transfers (transferring offline data), and local business interactions3 4 5.
Benefits of Conversion Tracking
The conversion tracking process provides the following benefits3;
- Keyword, ad, ad groups, and campaign performance measurement and optimization are made possible,
- Awareness of return on investment (ROI) is made possible, enabling ad spending to be kept under control,
- Campaigns can be automatically optimized according to business objectives (e.g., increasing conversions, targeting target cost per acquisition (CPA), target ROAS (Return on Ad Spend), and similar recommendation strategies).
Let’s now focus on the main topic.
Shopping Cart Data
Google Ads enables e-commerce websites to use shopping cart data for purchase and sale conversions. This allows a click on an ad for one product to trigger the sale of other products as well. Product data, after a user clicks on an ad, shows which products were purchased, which products have the highest probability of conversion, and which products are most frequently sold. As a result, sold products can gain detailed insights into revenue and profit generated by shopping ads, cart size, and average order value, among other metrics6 7.
Setting Up Conversion Reporting with Shopping Cart Data
For this process, the most basic requirement is that the Google Ads conversion tracking process must be implemented using GTM or GTAG.
If GA4 (Google Analytics 4) collects e-commerce data via GTAG (Global Site Tag) or GTM (Google Tag Manager), shopping cart data can be easily linked to relevant events using a similar object structure (with just a few simple modifications).
<script type="text/javascript">
gtag('event', 'purchase', {
"send_to": "AW-9999999999/abc123xyz",
"transaction_id": "1545c34e-691e-4726-aeda-b798df255e9c",
"value": 53.50,
"currency": "USD",
"discount": 1.50,
"aw_merchant_id": 98765, // optional
"aw_feed_country": "US",
"aw_feed_language": "EN",
"items": [{
"id": "P12345",
"quantity": 2,
"price": 12.50
},{
"id": "P67890",
"quantity": 1,
"price": 30.00
}]
});
</script>
As seen above, the purchase event is sent directly to a predefined Google Ads conversion event. Unlike the standard purchase object structure used in GA4 e-commerce reports, the event includes parameters such as aw_merchant_id (optional), aw_feed_country, and aw_feed_language at the cart level.
The aw_feed_language parameter can be used to specify which merchant account the item’s data should be associated with if the item is managed across multiple Merchant Center accounts.
The aw_feed_country and aw_feed_language use CLDR8 region codes to indicate the country associated with the product feed (feed) source.
In addition to the other parameters, the item_id within the items array is replaced with the id parameter. The discount parameter at the items level is instead placed at the higher-level transaction level.
I am also providing the code snippet for the purchase conversion event sent to GA4 e-commerce reports for clarity9.
<script type="text/javascript">
gtag("event", "purchase", {
transaction_id: "1545c34e-691e-4726-aeda-b798df255e9c",
affiliation: "Google Merchandise Store",
value: 53.50,
tax: 6.90,
shipping: 5.60,
currency: "USD",
coupon: "SUMMER_SALE",
items: [{
item_id: "P12345",
item_name: "Stan and Friends Tee",
affiliation: "Google Merchandise Store",
coupon: "SUMMER_FUN",
currency: "USD",
discount: 1.00,
index: 0,
item_brand: "Google",
item_category: "Apparel",
item_category2: "Adult",
item_category3: "Shirts",
item_category4: "Crew",
item_category5: "Short sleeve",
item_list_id: "related_products",
item_list_name: "Related Products",
item_variant: "green",
location_id: "L_12345",
price: 12.50,
quantity: 1
}, {
item_id: "P67890",
item_name: "Google Grey Women's Tee",
affiliation: "Google Merchandise Store",
coupon: "SUMMER_FUN",
currency: "USD",
discount: 0.50,
index: 1,
item_brand: "Google",
item_category: "Apparel",
item_category2: "Adult",
item_category3: "Shirts",
item_category4: "Crew",
item_category5: "Short sleeve",
item_list_id: "related_products",
item_list_name: "Related Products",
item_variant: "gray",
location_id: "L_12345",
price: 30.00,
promotion_id: "P_12345",
promotion_name: "Summer Sale",
quantity: 1
}]
});
</script>
Along with sending data to the Ads account (associated conversion label), the fields provided under the Conversions column will begin to display their values10.
The cart data fields are as follows:
Orders
: Sales associated with ad clicks.
Average cart size
: The total of the prices (price) of the items in the cart, divided by the number of orders.
Average order value
: The revenue generated from ad clicks, divided by the number of orders associated with ad clicks.
Cost of goods sold (COGS)
: The total operating costs attributed to a product. In other words, the cost of the goods sold.
Revenue
: The revenue generated from transactions associated with ad clicks. This value is calculated as the total price of all products in the shopping cart associated with a single ad click.
Gross profit
: The total profit generated from transactions associated with a single ad click. Calculated as Revenue - Cost of goods sold.
Testing Conversions with Shopping Cart Data
The code snippet illustrated above can be processed directly via GTAG or through the GTM tool. For example, the following Liquid code snippet can collect the required information about the purchased products on the Order Status Page of a Shopify e-commerce store, and store it in an array named orderProductsCart, which can then be called from the GTM - Ads conversion trigger, as part of the data layer.
{% for item in line_items %}
orderProductsCart.push({
'id': '{{ item.product_id }}',
'quantity': {{ item.quantity }},
'price': {{ item.line_price | times: 0.1 }}
});
{% endfor %}
Of course, the Provide product-level sales data option must be enabled within this tag.
Other fields can also be added as static or dynamic values, according to the parameter descriptions provided above.
In addition to viewing the relevant tag in GTM’s Preview mode, checking the browser’s Network tab is also beneficial.
The /conversion request can be used to separate a conversion event from other requests. The relevant request parameters must include the following: mid (aw_merchant_id), fcntr (aw_feed_country), flng (aw_feed_language), dscnt (discount), bttype (event type), item (items.id * items.price * items.quantity)7.
Once the columns in the report are reordered and saved, you can historically track conversions by cart details and begin optimizing your ads based on these data.
*[EBM]: Cost Per Action (CPA)
*[ROAS]: Return On Advertising Spend
*[CLDR]: Common Locale Data Repository
*[Conversions]: Conversions
Footnotes
- Measuring web conversions from Google Analytics 4 properties. Google Ads Support ↩
- Measuring app conversions from Google Analytics 4 properties. Google Ads Support ↩
- About conversion tracking. Google Ads Support ↩ ↩2
- Different ways to track conversions. Google Ads Support ↩
- CartData. Google Ads API ↩
- Tracking conversions with cart data. Google Ads Support ↩
- Setting up and testing conversion tracking with cart data (beta). Google Ads Support ↩ ↩2
- CLDR Charts ↩
- Purchase. Google Analytics 4 ↩
- Matt G. Southern. (2019). Google Ads Brings New Sets of Data to Shopping Campaigns ↩