Dynamic Remarketing allows you to show personalized ads to users based on their past interactions—like viewing a product, abandoning the cart, or checking out. For OpenCart, the most scalable way to enable this is using Google Tag Manager (GTM) with GA4 eCommerce data.
✅ What This Setup Will Track
Event | Use in Remarketing |
---|---|
view_item | Show product-based ads |
add_to_cart | Retarget cart abandoners |
purchase | Exclude converters |
view_item_list | List engagement-based retargeting |
🧰 Requirements
- OpenCart 3.x or 4.x access
- GA4 and GTM properly implemented
- Google Merchant Center linked to Google Ads
- Dynamic Remarketing feed approved
- Google Ads tag ID (e.g.,
AW-123456789
) - Product IDs in your OpenCart store match those in the Merchant Feed
🚀 Step-by-Step: Dynamic Remarketing in OpenCart via GA4 Data
🔹 Step 1: Format Product Data in GA4 Events
Update product and cart-related events in OpenCart to match Google’s dynamic remarketing parameters.
Example: Update catalog/controller/product/product.php
$product_id = (int)$this->request->get['product_id'];
$product_info = $this->model_catalog_product->getProduct($product_id);
$category = $this->model_catalog_category->getCategory($product_info['category_id']);
$data['gtm_view_item'] = json_encode([
'event' => 'view_item',
'ecommerce' => [
'items' => [[
'id' => $product_info['product_id'],
'name' => $product_info['name'],
'category' => $category['name'],
'price' => $product_info['price']
]]
]
]);
In product.twig
:
{% if gtm_view_item %}
<script>
window.dataLayer = window.dataLayer || [];
dataLayer.push({{ gtm_view_item|raw }});
</script>
{% endif %}
✅ This provides GA4-compliant product data that can also fuel remarketing.
🔹 Step 2: Push Cart Events (add_to_cart, begin_checkout, etc.)
In catalog/controller/checkout/cart.php
(for add_to_cart):
$data['gtm_add_to_cart'] = json_encode([
'event' => 'add_to_cart',
'ecommerce' => [
'items' => [[
'id' => $product_id,
'name' => $product_name,
'price' => $price,
'quantity' => $quantity
]]
]
]);
Then output in the response view (cart.twig
or AJAX template):
{% if gtm_add_to_cart %}
<script>
dataLayer.push({{ gtm_add_to_cart|raw }});
</script>
{% endif %}
🔹 Step 3: Create Data Layer Variables in GTM
Create GTM Data Layer Variables to access GA4 eCommerce values:
Name | Key |
---|---|
DLV - item_id |
ecommerce.items.0.id |
DLV - item_category |
ecommerce.items.0.category |
DLV - item_price |
ecommerce.items.0.price |
🔹 Step 4: Setup Google Ads Remarketing Tag in GTM
In GTM:
- Go to Tags > New
- Tag Type: Google Ads Remarketing
- Enter your Google Ads Conversion ID (
AW-XXXXXXXXX
) - Choose: Use custom parameters
- Enter the following key-value pairs:
ecomm_prodid: {{DLV - item_id}},
ecomm_pagetype: 'product',
ecomm_totalvalue: {{DLV - item_price}}
(For cart: pagetype = ‘cart’, for purchase: ‘purchase’)
- Trigger: Use Custom Event trigger for
view_item
🔹 Step 5: Create Triggers for Each Event
GTM Trigger | Type | Event Name |
---|---|---|
Trigger - view_item |
Custom Event | view_item |
Trigger - add_to_cart |
Custom Event | add_to_cart |
Trigger - purchase |
Custom Event | purchase |
Link each to its respective Google Ads Remarketing Tag with the correct ecomm_pagetype
.
🔹 Step 6: (Optional) Send to Google Analytics 4
You can send the same view_item
, add_to_cart
, and purchase
events to GA4 for reporting as well. Just create GA4 Event Tags with mapped parameters like:
items: [{
item_id: {{DLV - item_id}},
item_name: {{DLV - item_name}},
item_category: {{DLV - item_category}},
price: {{DLV - item_price}}
}]
🔹 Step 7: QA with GTM Preview and Tag Assistant
- Open GTM Preview mode
- Navigate through product, cart, and checkout pages
- Validate:
- Correct event is pushed (
view_item
,add_to_cart
, etc.) - Google Ads tag fires with right parameters
- Correct event is pushed (
- Use Google Tag Assistant → check that the
ecomm_prodid
andpagetype
match page context - In Google Ads > Audience Manager > Data Sources, confirm tag is receiving hits
🧠 Advanced: Page-Level Dynamic Parameters
For more precise control over dynamic remarketing:
Page | ecomm_pagetype |
---|---|
Homepage | 'home' |
Product page | 'product' |
Category | 'category' |
Cart | 'cart' |
Checkout | 'checkout' |
Purchase | 'purchase' |
Set this either in dataLayer
or directly in tag parameter configuration.
📦 Summary Table
Step | Action |
---|---|
1 | Push GA4 eCommerce-compatible product data on product pages |
2 | Track cart interactions using add_to_cart events |
3 | Create GTM Data Layer Variables for item data |
4 | Add Google Ads Remarketing Tag using custom parameters |
5 | Trigger per event type (view_item, add_to_cart, etc.) |
6 | QA with GTM Preview + Tag Assistant |
7 | Confirm tag firing in Google Ads → Audience Sources |