Integrating Google Analytics 4 (GA4) with Google Ads is a game changer for OpenCart merchants. With custom conversions, you can define your own success metrics, beyond just purchasesβlike form submissions, add-to-carts, or even scroll depthβand import them into Google Ads for bidding and attribution.
β Why Use Custom GA4 Conversions in Google Ads?
Feature | Benefit |
---|---|
Track micro-conversions | Add to cart, signup, scroll, etc. |
Smarter bidding | Optimize for user intent, not just purchases |
Full funnel visibility | Understand pre-purchase behavior |
Flexible attribution | Control which signals matter to Google Ads |
π§° Requirements
- GA4 property configured
- GTM web container implemented in OpenCart
- Google Ads and GA4 linked in the same Google account
- Event dataLayer pushes in OpenCart (e.g., add_to_cart, begin_checkout)
- GTM setup to fire GA4 custom events
π§© Example Use Case: Add-to-Cart as a Custom Conversion
Letβs say we want to:
- Send a custom
add_to_cart
event from OpenCart to GA4 - Mark it as a conversion
- Use it in Google Ads for audience building and bidding
πΉ Step 1: Push add_to_cart
to dataLayer in OpenCart
In catalog/controller/checkout/cart.php
, after the product is added:
$product_info = $this->model_catalog_product->getProduct($product_id);
$data['gtm_add_to_cart'] = json_encode([
'event' => 'add_to_cart',
'ecommerce' => [
'currency' => $this->session->data['currency'],
'value' => $product_info['price'],
'items' => [[
'item_id' => $product_info['model'], // Match Merchant Center
'item_name' => $product_info['name'],
'price' => $product_info['price'],
'quantity' => $quantity
]]
]
]);
Then in cart.twig
(or output file):
{% if gtm_add_to_cart %}
<script>
window.dataLayer = window.dataLayer || [];
dataLayer.push({{ gtm_add_to_cart|raw }});
</script>
{% endif %}
πΉ Step 2: Setup GA4 Event Tag in GTM
In Google Tag Manager:
- Tag Type: GA4 Event
- Configuration Tag: Your GA4 base config
- Event Name:
add_to_cart
(must match what you push) - Event Parameters:
currency
:{{DLV - ecommerce.currency}}
value
:{{DLV - ecommerce.value}}
items
:{{DLV - ecommerce.items}}
- Trigger:
- Type: Custom Event
- Event Name:
add_to_cart
Create all data layer variables as needed:
ecommerce.currency
ecommerce.value
ecommerce.items.0.item_id
, etc.
β
This sends the structured add_to_cart
event to GA4 with all necessary parameters.
πΉ Step 3: Verify in GA4 DebugView
- Go to GA4 β Admin β DebugView
- Add a product to cart
- Confirm
add_to_cart
event fires with:value
,currency
, anditem_id
πΉ Step 4: Mark the Custom Event as a Conversion in GA4
- In GA4 Admin β Events
- Locate
add_to_cart
in the list - Toggle the Mark as Conversion switch ON
β GA4 now treats this event as a conversion and can send it to Google Ads.
πΉ Step 5: Link GA4 with Google Ads
In GA4 Admin:
- Go to Product Links β Google Ads
- Click Link and choose your Ads account
- Enable:
- Personalized Advertising
- Auto-tagging
- Enable conversion import
β GA4 events marked as conversions will now be available in Ads.
πΉ Step 6: Import Conversions into Google Ads
- Go to Google Ads β Tools & Settings β Conversions
- Click New Conversion Action β Import β Google Analytics 4 properties (Web)
- Select
add_to_cart
or any other GA4-marked conversion - Assign a value or use the one from GA4
β Done! Your GA4 custom conversion is now available in Google Ads for:
- Smart bidding
- Audience segmentation
- Campaign performance tracking
π― Use Cases for Custom Conversions in OpenCart
Custom Event | Strategy |
---|---|
add_to_cart |
Target cart abandoners |
view_item |
Product-based engagement |
begin_checkout |
Pre-purchase signals |
newsletter_signup |
Lead-gen retargeting |
form_submit |
Micro-conversions in B2B stores |
π§ Pro Tips
- Name events consistently in dataLayer, GTM, and GA4
- Use transaction_id in purchase events to prevent duplicates
- GA4 sends conversions with event timestamp, ensuring accurate attribution
- Always test each step in GTM preview and GA4 DebugView before importing to Ads
π§ͺ QA Checklist
Task | β |
---|---|
add_to_cart fires in dataLayer |
β |
GA4 event tag sends event correctly | β |
Event visible in DebugView | β |
Event marked as conversion | β |
Imported to Google Ads | β |
Conversion appears in Ads reports | β |
π¦ Summary Table
Step | Description |
---|---|
1 | Push GA4-style event into OpenCart dataLayer |
2 | Fire GA4 event tag in GTM |
3 | Mark the event as a conversion in GA4 |
4 | Link GA4 to Google Ads |
5 | Import the custom event into Ads |
6 | Use it for bidding, targeting, and reports |