Enhanced Conversions for Google Ads via GTM in osCommerce (Full Setup + Code)

Standard

Enhanced Conversions help Google Ads recover conversion attribution lost due to privacy restrictions or third-party cookie limitations by sending hashed first-party customer data (e.g., email, phone, name) directly to Google. In osCommerce, implementing this via Google Tag Manager (GTM) ensures flexibility, privacy compliance, and minimal code repetition.

🎯 Why Use Enhanced Conversions?

  • Improves attribution accuracy
  • Boosts match rates for conversions (especially on iOS/Safari)
  • Supports smart bidding & remarketing effectiveness
  • Works with both standard and server-side GTM setups

βœ… Prerequisites

  • Google Ads Conversion Action already created
  • GTM installed on all osCommerce pages
  • checkout_success.php editable
  • Customer data (email, phone, etc.) available on order confirmation
  • GDPR/CCPA consent compliance in place (where applicable)

🧾 Step 1: Push Customer Data into the Data Layer (on Purchase)

In your checkout_success.php file, inject the customer data securely:

βœ… PHP + JavaScript Example:

<?php
$order = getOrderDetails($order_id);
?>

<script>
window.dataLayer = window.dataLayer || [];
dataLayer.push({
  event: 'purchase',
  transaction_id: '<?= $order['id'] ?>',
  value: <?= $order['total'] ?>,
  currency: 'USD',
  user_data: {
    email: "<?= $order['customer_email'] ?>",
    phone_number: "<?= $order['customer_phone'] ?>",
    first_name: "<?= $order['customer_firstname'] ?>",
    last_name: "<?= $order['customer_lastname'] ?>",
    address: {
      street: "<?= $order['customer_address'] ?>",
      city: "<?= $order['customer_city'] ?>",
      region: "<?= $order['customer_state'] ?>",
      postal_code: "<?= $order['customer_zip'] ?>",
      country: "<?= $order['customer_country'] ?>"
    }
  }
});
</script>

⚠️ Ensure that this is done only after explicit user consent where required.

🏷️ Step 2: Create Data Layer Variables in GTM

Go to Variables β†’ New β†’ Data Layer Variable. Create the following:

Variable Name Data Layer Variable Name
DL - email user_data.email
DL - phone_number user_data.phone_number
DL - first_name user_data.first_name
DL - last_name user_data.last_name
DL - address_street user_data.address.street
DL - address_city user_data.address.city
DL - address_region user_data.address.region
DL - address_postal_code user_data.address.postal_code
DL - address_country user_data.address.country

πŸ”§ Step 3: Create the Google Ads Conversion Tag with Enhanced Conversions

  1. Go to Tags β†’ New
  2. Choose Google Ads Conversion Tracking
  3. Enter your Conversion ID and Label
  4. Click β€œInclude Enhanced Conversions”
  5. Select: “Use data layer”
  6. Map the variables:
Enhanced Field GTM Variable
Email {{DL - email}}
Phone Number {{DL - phone_number}}
First Name {{DL - first_name}}
Last Name {{DL - last_name}}
Street Address {{DL - address_street}}
City {{DL - address_city}}
Region {{DL - address_region}}
Postal Code {{DL - address_postal_code}}
Country {{DL - address_country}}
  1. In the tag’s Conversion Value, use:
    • {{DL - value}} (set this up as a DL variable too)
  2. Trigger: Use a Custom Event Trigger for purchase

πŸ” Step 4: Configure Trigger for Purchase Event

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

πŸ§ͺ Step 5: Test the Enhanced Conversion Setup

βœ… Use GTM Preview:

  • Navigate to the thank-you page
  • Ensure:
    • purchase event is pushed
    • Google Ads Conversion tag fires

βœ… Use Google’s Enhanced Conversions Helper:

βœ… Chrome DevTools Check:

  • Open Network tab β†’ XHR
  • Look for request to googleads.g.doubleclick.net
  • Check payload includes hashed values (e.g., em, ph)

πŸ” Step 6: Privacy & Consent Considerations

To be GDPR/CCPA-compliant:

  • Only push user_data to the data layer after user consent
  • Use a Consent Management Platform (CMP) with GTM (e.g., Cookiebot, OneTrust)
  • Integrate with Consent Mode v2 in Google

🧠 Pro Tips for osCommerce Integration

Tip Benefit
Hash data before pushing to GTM (optional) Adds extra privacy on frontend
Combine with GA4 purchase tracking One tag β†’ multiple destinations
Implement via GTM Server-Side Even higher attribution & privacy control

βœ… Summary

With this setup, you now have:

  • βœ… Accurate Google Ads purchase conversion tracking
  • βœ… Enhanced Conversions via GTM using first-party customer data
  • βœ… Scalable, privacy-compliant setup for osCommerce

πŸ“ Optional Add-ons

  • πŸ”„ Server-side GTM setup for Enhanced Conversions
  • πŸ“‰ GA4 to Google Ads audience syncing
  • πŸ›’ Dynamic Remarketing using product data in osCommerce

Leave a Reply

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