Enabling Google Enhanced Conversion Tracking on your WooCommerce store allows you to send hashed first-party customer data (like email and phone) to Google Ads, improving conversion attribution and campaign performance. Here’s a step-by-step guide tailored for WordPress/WooCommerce users.
Set Up Conversion Actions in Google Ads**
- Log in to your Google Ads account.
- Go to Tools & Settings > Measurement > Conversions.
- Click New Conversion Action.
- Choose Website as the conversion source.
- Enter your WooCommerce store URL and follow the prompts to set up your conversion event (e.g., purchase, sign-up).
- Configure conversion settings (value, count, category).
- Enable Enhanced Conversions in the conversion action’s settings.
Enable Enhanced Conversions in WordPress/WooCommerce**
Replace your “AW-XXXXXXXXXX/XXXXXXXXXX” Conversion id from google ads, To find this ID, Go to your ads account, click conversions, select a google ads conversion (not google analytics one) and then click edit, expand Google Tag at the end and copy the ID from there. you might need to create a conversion action if you can't find Google Tag or any conversion actions
add_action('woocommerce_thankyou', function ($order_id) {
if (!$order_id) return;
$order = wc_get_order($order_id);
if (!$order) return;
// Get customer data
$email = esc_js($order->get_billing_email());
$phone = esc_js($order->get_billing_phone());
$first_name = esc_js($order->get_billing_first_name());
$last_name = esc_js($order->get_billing_last_name());
$address1 = esc_js($order->get_billing_address_1());
$city = esc_js($order->get_billing_city());
$region = esc_js($order->get_billing_state());
$postal = esc_js($order->get_billing_postcode());
$country = esc_js($order->get_billing_country());
$total = esc_js($order->get_total());
$currency = esc_js($order->get_currency());
$transaction_id = esc_js($order->get_order_number());
$conversion_id_label = 'AW-XXXXXXXXXX/XXXXXXXXXX';
?>
<script>
gtag('set', 'user_data', {
"email": "<?php echo $email; ?>",
"phone_number": "<?php echo $phone; ?>",
"address": {
"first_name": "<?php echo $first_name; ?>",
"last_name": "<?php echo $last_name; ?>",
"street": "<?php echo $address1; ?>",
"city": "<?php echo $city; ?>",
"region": "<?php echo $region; ?>",
"postal_code": "<?php echo $postal; ?>",
"country": "<?php echo $country; ?>"
}
});
gtag('event', 'conversion', {
'send_to': '<?php echo $conversion_id_label; ?>',
'value': <?php echo $total ? floatval($total) : 0; ?>,
'currency': '<?php echo $currency; ?>',
'transaction_id': '<?php echo $transaction_id; ?>'
});
</script>
<?php
});
Test and Verify
- Make a test purchase in your WooCommerce store.
- Use the Google Tag Assistant or Chrome DevTools to verify that enhanced conversion data is being sent.
- In Google Ads, check the conversion action’s status to confirm data is received and enhanced conversions are active, it will take some and advisable, don't trigger it more than once.