For effective Google Ads Dynamic Remarketing, you need to ensure that the product IDs in your OpenCart events match the product IDs in your Google Merchant Center (GMC) feed. Without a perfect match, your ads wonβt show the right products or may not appear at all.
β Why Matching Product IDs Matters
Element | Must Match |
---|---|
GA4/GTM ecomm_prodid |
Merchant feed id |
Price in GTM | Feed product price (optional but recommended) |
Category (optional) | Helps with audience segmentation |
π§° Requirements
- OpenCart store (v3.x or v4.x)
- Google Merchant Center account and approved product feed
- Google Ads linked to Merchant Center
- GTM container installed on your site
- Feed uses Product ID (SKU or model) as
id
field
π Step-by-Step: Match OpenCart Product Data to Merchant Center IDs
πΉ Step 1: Decide Your Feed Identifier Strategy
Check your Google Merchant Center product feed:
- Is the product ID the SKU?
- Or the model number?
- Or the OpenCart product ID?
Most feeds are set up with the model number or SKU.
π Youβll need to send the same value in the ecomm_prodid
for GTM dynamic remarketing.
πΉ Step 2: Modify product.php
Controller to Include Correct Product ID
Edit: catalog/controller/product/product.php
$product_id = (int)$this->request->get['product_id'];
$product_info = $this->model_catalog_product->getProduct($product_id);
$data['gtm_view_item'] = json_encode([
'event' => 'view_item',
'ecommerce' => [
'items' => [[
'id' => $product_info['model'], // Use model to match GMC feed
'name' => $product_info['name'],
'category' => 'Replace with category if available',
'price' => $product_info['price']
]]
]
]);
π Replace 'model'
with 'sku'
if thatβs what your Merchant feed uses.
β This ensures the same ID is used in both feed and event.
πΉ Step 3: Output the DataLayer Script in the Product Page
In product.twig
:
{% if gtm_view_item %}
<script>
window.dataLayer = window.dataLayer || [];
dataLayer.push({{ gtm_view_item|raw }});
</script>
{% endif %}
β
This outputs the view_item
event in a GA4/eCommerce-ready format.
πΉ Step 4: Add the Same Product ID to Cart Events
In catalog/controller/checkout/cart.php
or via AJAX response:
$data['gtm_add_to_cart'] = json_encode([
'event' => 'add_to_cart',
'ecommerce' => [
'items' => [[
'id' => $product_info['model'], // Same match as above
'name' => $product_info['name'],
'price' => $product_info['price'],
'quantity' => $quantity
]]
]
]);
πΉ Step 5: Create GTM Variables for ID Matching
In GTM:
- DLV – item_id β
ecommerce.items.0.id
- DLV – item_name β
ecommerce.items.0.name
- DLV – item_price β
ecommerce.items.0.price
β Use these for dynamic remarketing and GA4 event tagging.
πΉ Step 6: Setup Google Ads Remarketing Tag in GTM
- Tag Type: Google Ads Remarketing
- Conversion ID: From your Google Ads account
- Custom Parameters:
ecomm_prodid: {{DLV - item_id}},
ecomm_pagetype: 'product',
ecomm_totalvalue: {{DLV - item_price}}
- Trigger: Custom Event:
view_item
π Use different ecomm_pagetype
values for cart, category, checkout, etc.
πΉ Step 7: Validate Product Feed in Merchant Center
- Go to Google Merchant Center β Products β Feeds
- Download your product feed
- Confirm the
id
column matches the values you’re pushing asecomm_prodid
in GTM - Ensure no mismatch or null values exist
β If youβre using GTIN or SKU as ID in the feed, use the same value in OpenCart events.
πΉ Step 8: Test with Google Tag Assistant + GA4 DebugView
- Open your product page
- In Tag Assistant:
- Look for
view_item
event - Confirm
ecomm_prodid
matches your Merchant feed
- Look for
- In GA4 DebugView:
- Confirm
item_id
equals Merchant Center product ID
- Confirm
π Bonus: Output Category for Dynamic Audiences
You can add category dynamically too:
$categories = $this->model_catalog_product->getCategories($product_id);
$category_id = $categories[0]['category_id'];
$category_info = $this->model_catalog_category->getCategory($category_id);
$category_name = $category_info['name'];
And then:
'category' => $category_name
β You can later segment audiences in Google Ads based on category pageviews.
π§ Best Practices
Practice | Tip |
---|---|
Feed ID must match OpenCart ID exactly | Including case-sensitivity and format |
Test real product examples | Validate with Tag Assistant and live feed |
Always sanitize null or invalid IDs | Prevents tracking errors |
Update IDs if feed structure changes | Keep events and feed aligned |
Add default fallback values | For products missing SKU or model |
π¦ Summary
Step | Action |
---|---|
1 | Verify Merchant feed ID structure (model/SKU) |
2 | Output same product ID in OpenCart events |
3 | Modify product.php and cart.php for consistency |
4 | Create GTM DLVs for ID, name, price |
5 | Configure Google Ads Remarketing tag with those values |
6 | Confirm match in Merchant Center |
7 | QA via GTM Preview and Google Tag Assistant |