Articles on: Server Side
This article is also available in:

How to Send Lead Data with UTM Parameters via Webhooks

This guide explains how to capture and forward lead generation data, including UTM parameters and marketing attribution data, to external platforms using webhooks through Google Tag Manager Server-Side.


Overview

When a visitor converts on your website, you often want to send this conversion data along with marketing attribution information to external platforms for further processing, CRM integration, or automation workflows.


Overview of technical flow



What Data Can Be Captured?


Lead Information

  • Form submission data (name, email, phone, etc.)
  • User behavior data
  • Page information where conversion occurred
  • Timestamp of conversion

Marketing Attribution Data

  • UTM Parameters: utm_source, utm_medium, utm_campaign, utm_term, utm_content
  • Platform Tracking IDs: Google Click ID (gclid), Facebook Click/Browser ID (fbc/fbp), TikTok Click ID (ttclid)
  • Session Data: Session ID, session count, user agent
  • Traffic Source: Referrer URL, landing page



This only works if you have GravityForms or ContactForm 7 forms on your Wordpress website. Other CMS systems are not compatible with this feature.



Setting Up Webhook Integration


Prerequisites

  • Google Tag Manager Server-Side container configured
  • AdPage tracking implementation on your website
  • Webhook endpoint from your chosen platform (Zapier, Make, or N8N)


You can also choose to download the import template of sGTM here: GTM generate_lead webhook



Step 1: Configure the Webhook Client

You can download and import the Webhook client by going to this URL: GitHub AdPage Webhook client


Make sure /order_created is added as extra event setting



The AdPage Webhook Client automatically parses incoming lead data and structures it for forwarding. It handles:

javascript

// Example of parsed data structure
{
"event_name": "trytagging_generate_lead",
"form_data": {
"name": "John Doe",
"email": "john@example.com",
"phone": "+1234567890"
},
"marketing": {
"utm_source": "google",
"utm_medium": "cpc",
"utm_campaign": "summer-sale",
"gclid": "abc123...",
"fbp": "fb.1.1234567890",
"user_agent": "Mozilla/5.0...",
"ip": "192.168.1.1"
},
"user_data": {
"first_name": "John",
"last_name": "Doe",
"email": "john@example.com",
"phone": "+1234567890"
}
}



Step 2: Create HTTP Request Tag


Configure the JSON HTTP Request tag to forward data to your chosen platform:

  1. URL: Your webhook endpoint URL
  2. Method: POST
  3. Headers: Content-Type: application/json
  4. Body: Include form_data and marketing variables


You can download or use the Gallery feature of Google Tag Manager server side to use the HTTP request tag of Stape: HTTP request tag


Setup with HTTP tag setup



Step 3: Set Up Trigger

Create a trigger that fires when lead data is received:

  • Trigger Type: Custom Event or Always
  • Conditions:
    • Event Name contains "generate_lead" or similar
    • Client Name contains "Webhook"


Make sure you have the same triggers




Testing Your Setup


1. Use GTM Preview Mode

  • Enable preview mode in GTM and use Webhook testing
  • Submit a test form on your website
  • Verify the webhook tag fires correctly
  • Check the data being sent


Example with only name variables



2. Webhook Testing Tools

  • Webhook.site: Create temporary webhook URLs for testing
  • Postman: Test webhook endpoints manually
  • Platform test features: Most platforms offer webhook testing utilities


3. Verify Data Reception

  • Check your chosen platform's webhook logs
  • Verify all expected fields are received
  • Test data formatting and structure




Troubleshooting


Common Issues


Webhook Not Firing:

  • Check trigger conditions
  • Verify event names match
  • Ensure client is properly configured


Missing Data:

  • Verify variable configurations
  • Check data layer implementation
  • Confirm marketing data is being captured


Platform Integration Issues:

  • Validate webhook URL format
  • Check authentication requirements
  • Verify platform-specific payload structure


Debugging Tips

  1. Enable Logging: Set log type to "Always log to console"
  2. Use Debug Headers: Add trace-id for request tracking
  3. Test Incrementally: Start with basic data, add complexity gradually
  4. Monitor Response Codes: Check for 200 OK responses



Security Considerations


Data Protection

  • Only send necessary data fields
  • Consider data encryption for sensitive information
  • Implement proper access controls on webhook endpoints

Webhook Security

  • Use HTTPS endpoints only
  • Implement webhook signature verification when available
  • Set up proper authentication headers

Best Practices

  1. Error Handling: Configure timeout and retry logic
  2. Data Validation: Validate data before sending
  3. Monitoring: Set up alerts for failed webhooks
  4. Documentation: Maintain clear documentation of data mappings
  5. Testing: Regularly test webhook functionality


Conclusion

Webhook integration allows you to seamlessly forward lead data with complete marketing attribution to your preferred automation platforms. By following this guide, you can ensure comprehensive lead tracking that maintains the full customer journey context from first click to conversion.

For technical support or advanced configurations, contact your implementation team or refer to platform-specific documentation.









Updated on: 06/08/2025

Was this article helpful?

Share your feedback

Cancel

Thank you!