Google Ads Conversion Tracking in osCommerce with GTM

Standard

Setting up Google Ads Conversion Tracking in osCommerce through Google Tag Manager (GTM) allows you to accurately measure post-click performance, optimize campaigns, and unlock Smart Bidding features. This guide walks you through a robust, conversion-accurate setup tailored for osCommerce stores.

โœ… Why Track Google Ads Conversions via GTM?

  • Centralizes tag management without editing theme files
  • Enables dynamic values for conversion tracking (revenue, ID, etc.)
  • Reduces code clutter and improves accuracy
  • Facilitates advanced setups like remarketing and enhanced conversions

๐Ÿงฐ Prerequisites

  • Google Tag Manager installed across all osCommerce pages
  • Google Ads account with conversion actions created
  • Access to osCommerce checkout_success.php
  • Google Ads Conversion ID & Label

๐Ÿ“ฆ Step 1: Create a Conversion Action in Google Ads

  1. Go to Tools & Settings โ†’ Conversions
  2. Click New conversion action โ†’ Website
  3. Choose Category: Purchase or Lead
  4. Set Conversion Name, Value, and Count settings
  5. Choose Tag Setup โ†’ Use Google Tag Manager
  6. Copy your Conversion ID and Conversion Label

๐Ÿ›’ Step 2: Push Purchase Data to the Data Layer in osCommerce

In your checkout_success.php file, dynamically inject conversion data like transaction ID, total value, and currency.

โœ… PHP + JavaScript Example:

<?php
$order = getOrderDetails($order_id); // Your backend logic
$items = [];

foreach ($order['products'] as $product) {
  $items[] = [
    'id' => $product['model'],
    'name' => $product['name'],
    'price' => $product['price'],
    'quantity' => $product['quantity']
  ];
}
?>

<script>
window.dataLayer = window.dataLayer || [];
dataLayer.push({
  event: 'purchase',
  transaction_id: '<?= $order['id'] ?>',
  value: <?= $order['total'] ?>,
  currency: 'USD',
  items: <?= json_encode($items) ?>
});
</script>

๐Ÿง  Step 3: Create a Trigger in GTM

  1. Go to Triggers โ†’ New
  2. Trigger Type: Custom Event
  3. Event Name: purchase
  4. Name it: Trigger - Purchase Event

๐Ÿท๏ธ Step 4: Create the Google Ads Conversion Tag

  1. Go to Tags โ†’ New
  2. Tag Type: Google Ads Conversion Tracking
  3. Enter your Conversion ID and Label
  4. Conversion Value:
    • Click the icon to add variable
    • Use {{DL - value}} (create this in the next step)
  5. Transaction ID: {{DL - transaction_id}} (optional but recommended)
  6. Currency Code: {{DL - currency}}
  7. Trigger: Use Trigger - Purchase Event

๐Ÿ”ง Step 5: Create Data Layer Variables in GTM

Go to Variables โ†’ New โ†’ Data Layer Variable

Variable Name Data Layer Variable Name
DL - value value
DL - transaction_id transaction_id
DL - currency currency

Set Version: Version 2 and leave “Data Layer Version” untouched.

๐Ÿ” Step 6: Test the Implementation

  1. Enable Preview Mode in GTM
  2. Go to your site and complete a test purchase
  3. Ensure:
    • The purchase event fires
    • The Google Ads Conversion Tag triggers
    • Correct values (value, currency, transaction_id) are sent
  4. Use Google Tag Assistant and Google Ads Conversion Debug Tool to verify success

๐Ÿ” Optional: Enhanced Conversions for Web

To improve attribution and match rates, enable Enhanced Conversions:

Prerequisites:

  • First-party customer data (email, phone, etc.)
  • Consent is collected if required (GDPR/CCPA compliance)

Add to checkout_success.php:

dataLayer.push({
  user_data: {
    email: "<?= $order['customer_email'] ?>",
    phone_number: "<?= $order['customer_phone'] ?>"
  }
});

In the GTM Google Ads Conversion Tag โ†’ Enable Enhanced Conversions โ†’ Map variables from the Data Layer.

๐Ÿ“Š Step 7: Monitor Conversions in Google Ads

  • Go to Tools & Settings โ†’ Conversions
  • Check if conversions are being recorded (may take up to 24h)
  • Use filters to break down by campaign, ad group, and keyword

๐Ÿ’ก CRO Tips Post-Setup

Observation Optimization Tactic
Low conversion rate Improve checkout flow or trust UX
High cart abandonment Set up remarketing or email recovery
Delayed conversions Consider using Data-Driven Attribution
Value discrepancies Check dynamic value passing accuracy

โœ… Summary

Youโ€™ve now implemented complete Google Ads Conversion Tracking in osCommerce using GTM, including:

  • Dynamic revenue and transaction data
  • Triggered conversion tags based on purchase events
  • Scalable setup for Enhanced Conversions and remarketing

๐Ÿ“ Optional Add-ons

  • Google Ads Remarketing Tag via GTM
  • Server-side GTM for privacy-compliant attribution
  • Google Analytics 4 + Ads linking for audience sync

 

Leave a Reply

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