Implementing Google Ads Conversion Tracking in OpenCart via GTM

Standard

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

  1. Go to your Google Ads account
  2. Navigate to Tools & Settings β†’ Conversions
  3. Click + New Conversion Action
  4. Choose Website
  5. 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
  6. Click Create and Continue
  7. Select Use Google Tag Manager
  8. Note down:
    • Conversion ID: e.g., AW-123456789
    • Conversion Label: e.g., XyZAbc1234


πŸ”Ή 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

  1. Go to Tags β†’ New
  2. Tag Type: Google Ads Conversion Tracking
  3. Fill in:
    • Conversion ID: from Step 1
    • Conversion Label: from Step 1
  4. Click Enable value tracking
  5. Set:
    • Conversion Value: {{DLV - value}}
    • Transaction ID: {{DLV - transaction_id}}
    • Currency Code: {{DLV - currency}}
  6. Trigger: Event - Purchase
  7. 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:

  1. In GTM, create a variable:
    • Type: DOM Element
    • Selector: input[name="email"]
    • Attribute: value
  2. 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

  1. Enable GTM Preview Mode
  2. Place a test order in your OpenCart store
  3. Confirm the purchase event appears in Preview mode
  4. Confirm Google Ads Conversion Tag fires
  5. Use Google Tag Assistant to validate tag
  6. 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


Leave a Reply

Your email address will not be published. Required fields are marked *