π Advanced Guide: Implementing Google Ads Enhanced Conversions with Server-Side Tagging
π What Are Enhanced Conversions?
Enhanced Conversions for Google Ads allow you to send first-party customer data (e.g., email, name, phone number) to Google in a hashed format (SHA-256). This improves conversion tracking accuracy, especially in privacy-restricted environments like iOS or with cookie restrictions.
When paired with Server-Side Tagging, you gain:
- Better data control
- Improved user privacy compliance
- Reduced client-side load
- Enhanced tracking resilience
π οΈ Tools Youβll Need
- Google Tag Manager (Web + Server Container)
- Google Ads Account with Conversion Tracking Setup
- Google Cloud Platform (GCP) for deploying the server container
- Access to your website code (to extract and send user data)
π Architecture Overview
[User Browser] β [Web GTM] β [Send User Data] β
β [Server GTM (on GCP)] β [Google Ads Enhanced Conversion API]
π§ Step 1: Set Up Google Ads Enhanced Conversions
- Go to Google Ads β Tools & Settings β Conversions.
- Create or select a conversion action.
- Enable Enhanced Conversions under “Enhanced Conversions” section.
- Choose the API method (for server-side).
- Accept terms and save.
ποΈ Step 2: Create Web GTM Tag to Send Data
You need to collect PII data (email, name, phone, etc.) on the client side and pass it to the server container.
π§© Add Custom JavaScript Variable
In Web GTM, create a JavaScript Variable to extract user PII (e.g., from checkout form):
function() {
return {
email: document.querySelector('#email')?.value,
phone: document.querySelector('#phone')?.value,
first_name: document.querySelector('#first-name')?.value,
last_name: document.querySelector('#last-name')?.value
};
}
π·οΈ Create a Custom Tag to Send Data to Server
Create a new Tag (Tag Type: HTTP Request or Custom Image) in Web GTM:
- Tag Type: Custom Image Tag
- URL:
https://<your-server-container-url>/collect
- Custom Parameters (Query String): plaintextCopyEdit
email={{User Data.email}}&phone={{User Data.phone}}&first_name={{User Data.first_name}}&last_name={{User Data.last_name}}&conversion_id=AW-CONVERSION_ID&event_name=purchase
Fire this tag on conversion trigger (e.g., “Purchase Complete”).
π₯οΈ Step 3: Deploy Server-Side GTM Container
- In GTM, create a Server Container.
- Deploy it on Google Cloud App Engine:
- Google will guide you through provisioning the App Engine.
- Youβll get a server URL like:
https://gtm-yourproject.uc.r.appspot.com
- Enable Enhanced Conversions in your container.
π Step 4: Create a Custom Client in Server Container
Create a Client to parse the incoming HTTP request from the web container.
βοΈ Client Code Example
// Enhanced Conversion Client in Server GTM
const parsedUrl = require('url').parse(request.url, true);
const query = parsedUrl.query;
const userData = {
email: query.email,
phone_number: query.phone,
first_name: query.first_name,
last_name: query.last_name,
conversion_id: query.conversion_id,
event_name: query.event_name
};
// Assign data to event object
eventData = {
user_data: userData,
event_name: query.event_name,
conversion_id: query.conversion_id
};
// Send to tags
return {
eventData,
logType: 'INFO'
};
π§© Step 5: Set Up Google Ads Enhanced Conversions Tag in Server GTM
- Go to Tags β New β Tag Configuration.
- Select Google Ads Conversion Tracking.
- Fill out the following:
- Conversion ID:
AW-XXXXXXXXX
- Conversion Label: Your label from Ads
- User Data: Map the fields from the
eventData
- Email:
{{eventData.user_data.email}}
- Phone:
{{eventData.user_data.phone_number}}
- First Name:
{{eventData.user_data.first_name}}
- Last Name:
{{eventData.user_data.last_name}}
- Email:
- Conversion ID:
- Hash PII using built-in hashing functions (or pre-hash on client).
Note: Google requires SHA-256 hashing. Server GTM does this automatically if you pass raw values and set “Hash data” to TRUE.
π§ͺ Step 6: Test and Debug
- Use Preview Mode in Web GTM to ensure tag fires with PII.
- Use Server GTM Preview to verify:
- Client receives request
- Event data is parsed
- Google Ads Tag is fired with correct payload
- In Google Ads:
- Go to Conversions β Check Enhanced Conversions column
- It should say “Recording (API)” after some time.
β Best Practices
- Consent Mode: Ensure PII is only sent with user consent (GDPR/CCPA).
- Hashing: Use SHA-256 for any data thatβs sent unhashed.
- Security: Use HTTPS and authenticate requests to prevent misuse.
- Data Layer: Use a structured data layer to manage PII cleanly.
π‘ Bonus: Optional – Use Cloud Function to Pre-Process
If you want to hash on server manually or process complex logic:
Example Google Cloud Function (Node.js)
const crypto = require('crypto');
exports.enhancedConversion = (req, res) => {
const data = req.query;
function hash(value) {
return crypto.createHash('sha256').update(value.trim().toLowerCase()).digest('hex');
}
const hashedData = {
email: hash(data.email),
phone: hash(data.phone),
first_name: hash(data.first_name),
last_name: hash(data.last_name)
};
// Send to Server GTM or Google Ads API
// Example: res.redirect(`https://gtm-server-url.com/collect?...`);
res.status(200).send('Data processed and hashed.');
};
Deploy it and replace the Web GTM tagβs URL with your function’s URL.
π Conclusion
mplementing Enhanced Conversions with Server-Side Tagging helps improve attribution accuracy while enhancing user privacy. While it involves multiple components (client, server, GTM, Ads), the modular nature of GTM makes it scalable and manageable.