Google Analytics 4 (GA4) allows you to build highly-targeted behavior-based audiences for retargeting in Google Ads. When integrated with OpenCart, GA4 can segment users based on their interactions—such as product views, cart activity, or checkout behavior—and send these audiences to Google Ads for remarketing.
🧰 Prerequisites
Requirement | Description |
---|---|
OpenCart 3.x or 4.x | Your eCommerce platform |
GA4 Property | Installed via GTM |
Google Tag Manager | Web container active on OpenCart |
Google Ads Account | Linked to GA4 (for remarketing) |
Consent Management | Recommended for compliant tracking |
🧱 Step 1: Inject Custom Events into OpenCart
A. Product Detail Page – view_item
In product.twig
:
<script>
window.dataLayer = window.dataLayer || [];
dataLayer.push({
event: 'view_item',
ecommerce: {
items: [{
item_id: '{{ product_id }}',
item_name: '{{ heading_title }}',
item_category: '{{ category }}',
price: {{ price }},
quantity: 1
}]
}
});
</script>
B. Add to Cart Event – add_to_cart
In your JS click handler or via GTM click trigger:
dataLayer.push({
event: 'add_to_cart',
ecommerce: {
items: [{
item_id: '123',
item_name: 'Sample Product',
price: 19.99,
quantity: 1
}]
}
});
C. Begin Checkout – begin_checkout
In checkout.twig
:
<script>
dataLayer.push({
event: 'begin_checkout',
ecommerce: {
items: [{
item_id: '{{ item_id }}',
item_name: '{{ name }}',
price: '{{ price }}',
quantity: 1
}]
}
});
</script>
📦 Step 2: Configure GA4 Tags in GTM
For each custom event above:
- Tag Type: GA4 Event
- Configuration Tag: Your GA4 ID tag
- Event Name: Match
view_item
,add_to_cart
, etc. - Event Parameters:
items
: Use a Data Layer Variable that holdsecommerce.items
Example – GA4 Add to Cart Tag
- Event Name:
add_to_cart
- Parameters:
items
={{DLV - ecommerce.items}}
✅ Repeat this for all funnel steps: view_item
, add_to_cart
, begin_checkout
, purchase
🔄 Step 3: Enable Google Ads Remarketing via GA4
- Go to GA4 > Admin > Product Links > Google Ads
- Link your Google Ads account
- Enable the checkbox: “Enable Personalized Advertising”
🧲 Step 4: Create Audiences in GA4
A. Viewers But No Cart
Condition:
- Event =
view_item
- AND does not include event =
add_to_cart
within last 7 days
B. Cart Abandoners
Condition:
- Event =
add_to_cart
- AND not
purchase
within 3 days
C. Checkout Starters, No Purchase
Condition:
- Event =
begin_checkout
- AND not
purchase
within 1 day
🛠 Step 5: Send Audiences to Google Ads
Once the Google Ads link is active:
- Go to GA4 > Admin > Audiences
- Click into your audience → Enable “Google Ads Audience Activation”
- These audiences will now appear in Google Ads > Tools > Audience Manager
Use them in campaigns like:
- Dynamic Display Ads
- Performance Max
- Standard Remarketing Campaigns
🔐 Step 6: Consent Mode (Optional)
To delay audience data collection until user consent:
- Set up GTM Consent Mode
- Delay GA4 event tags until
"analytics_storage"
is granted - Example:
<script>
if (window.consent_granted === true) {
dataLayer.push({ event: 'view_item', ecommerce: { ... }});
}
</script>
🧪 Step 7: QA & Debugging
Tool | Use Case |
---|---|
GTM Preview Mode | Validate event payloads |
GA4 DebugView | Inspect events in real-time |
Google Ads Audience | Check audience size over time |
🎯 Strategic Benefits
- Build precise retargeting funnels from behavioral triggers
- Engage non-converting users with custom creative
- Feed audiences to multiple Google Ads formats
- Zero reliance on 3rd-party cookies (first-party GA4 data only)