To accurately measure ROI from Google Ads campaigns in your OpenCart store, it’s essential to implement conversion tracking using Google Tag Manager (GTM). When users complete a purchase, a conversion should be recorded and tied back to their ad click.
β What This Implementation Tracks
| Metric | Description |
|---|---|
| Conversion | When a purchase is completed |
| Conversion Value | Total revenue from order |
| Transaction ID | Unique order reference to prevent duplicates |
| Currency | Currency used for the purchase |
π§° Requirements
- OpenCart admin + FTP access
- GTM container installed in OpenCart
- Google Ads account with a conversion action created
- Google Ads Conversion ID and Label
- Basic PHP + Twig editing capability
π Step-by-Step: Google Ads Conversion Tracking in OpenCart via GTM
πΉ Step 1: Create a Google Ads Conversion Action
- Go to your Google Ads account
- Navigate to Tools & Settings β Conversions
- Click + New Conversion Action
- Choose Website
- Enter conversion settings:
- Category: Purchase
- Conversion name: Purchase Conversion
- Value: Use different values for each conversion
- Count: One per conversion
- Click-through window: 30 days
- Click Create and Continue
- Select Use Google Tag Manager
- Note down:
- Conversion ID: e.g.,
AW-123456789 - Conversion Label: e.g.,
XyZAbc1234
- Conversion ID: e.g.,
πΉ Step 2: Inject Dynamic Conversion Data into dataLayer in OpenCart
Edit catalog/controller/checkout/success.php:
$order_id = $this->session->data['order_id'];
$this->load->model('checkout/order');
$order_info = $this->model_checkout_order->getOrder($order_id);
$data['google_ads_conversion'] = json_encode([
'event' => 'purchase',
'transaction_id' => $order_info['order_id'],
'value' => $order_info['total'],
'currency' => $order_info['currency_code']
]);
Now edit success.twig (usually located in catalog/view/theme/YOUR_THEME/template/checkout/):
{% if google_ads_conversion %}
<script>
window.dataLayer = window.dataLayer || [];
dataLayer.push({{ google_ads_conversion|raw }});
</script>
{% endif %}
β
This pushes the conversion event into the dataLayer only after a successful purchase.
πΉ Step 3: Create GTM Data Layer Variables
In your GTM container, go to Variables β New β Data Layer Variable and create:
| Name | Data Layer Variable |
|---|---|
DLV - transaction_id |
transaction_id |
DLV - value |
value |
DLV - currency |
currency |
πΉ Step 4: Create the Conversion Trigger
Go to Triggers β New
- Trigger Type: Custom Event
- Event Name:
purchase - Trigger fires on: All Custom Events
- Name it:
Event - Purchase
πΉ Step 5: Add Google Ads Conversion Tag in GTM
- Go to Tags β New
- Tag Type: Google Ads Conversion Tracking
- Fill in:
- Conversion ID: from Step 1
- Conversion Label: from Step 1
- Click Enable value tracking
- Set:
- Conversion Value:
{{DLV - value}} - Transaction ID:
{{DLV - transaction_id}} - Currency Code:
{{DLV - currency}}
- Conversion Value:
- Trigger:
Event - Purchase - Save and name:
Google Ads Conversion - Purchase
β
This tag fires when the purchase event is pushed to the dataLayer with value and transaction ID.
πΉ Step 6: (Optional) Setup Enhanced Conversions via CSS Selectors
If you want to enhance conversion data using email or phone number from checkout, you can add Enhanced Conversions:
- In GTM, create a variable:
- Type: DOM Element
- Selector:
input[name="email"] - Attribute:
value
- In your Google Ads Conversion Tag:
- Enable Enhanced Conversions
- Select Email variable
This is optional but improves attribution accuracy.
πΉ Step 7: Test Everything in GTM & GA
- Enable GTM Preview Mode
- Place a test order in your OpenCart store
- Confirm the
purchaseevent appears in Preview mode - Confirm Google Ads Conversion Tag fires
- Use Google Tag Assistant to validate tag
- In Google Ads β Conversions β Status: check for incoming conversions within 24 hours
π Optional: Deduplicate Conversion Events in GA4 + Google Ads
If youβre also sending purchase data to GA4 and importing conversions, deduplicate using:
- Matching
transaction_id - Mark one conversion source as primary
π Summary Table
| Step | Action |
|---|---|
| 1 | Create conversion in Google Ads |
| 2 | Inject conversion data in dataLayer on success page |
| 3 | Create GTM variables for transaction_id, value, currency |
| 4 | Add custom event trigger for purchase |
| 5 | Configure Google Ads conversion tag with dynamic values |
| 6 | (Optional) Add Enhanced Conversions |
| 7 | Test with Tag Assistant and debug tools |
