LinkedIn Conversion API with sGTM
Implementing LinkedIn Conversions API through Google Tag Manager using Hardal server-side
Overview
This guide explains how to implement LinkedIn Conversions API (CAPI) using Google Tag Manager (GTM) and server-side GTM through Hardal’s server-side infrastructure. This implementation provides more reliable conversion tracking by sending data directly from your server to LinkedIn.
Prerequisites
Before beginning this implementation, ensure you have:
- A Hardal account
- A server-side GTM container
- A web GTM container installed on your website
- A LinkedIn Campaign Manager account with admin access
- Google Analytics 4 (GA4) implemented on your website
Implementation Steps
Deploy a Server Container in GTM
First, you need to set up a server-side GTM container in Hardal.
- Follow Server-side Google Tag Manager guide to get ready.
If you’ve already set up server-side GTM in Hardal, you can skip this step and use your existing setup.
Configure GA4 Client in Server Container
In your server-side GTM container:
- Go to “Clients” and ensure the built-in “GA4” client is configured
- Set the following parameters:
- Priority: 0 (default)
- Default GA4 paths: Enabled
- Default gtag.js paths: Enabled with your GA4 Measurement ID(s)
- Automatically serve dependent scripts: Enabled
- Compress HTTP response: Enabled
- Enable region-specific settings: Enabled with Visitor Region variable
- Cookies and Client Identification: Server Managed
The GA4 client is essential as it will parse incoming GA4 requests from your website and make the data available to your LinkedIn CAPI tag.
Add LinkedIn CAPI Tag to Server Container
- In your server-side GTM container, go to “Tags” and click “New”
- Click “Discover more tag types in the Community Template Gallery”
- Search for “LinkedIn | CAPI Tag Template” from linkedin-developers
- Click “Add to Workspace”
- Add all information required by the tag
- LinkedIn API Access Token Access your LinkedIn API Token
- LinkedIn Conversion Rule ID Access your LinkedIn Conversion Rule ID
- EventID
- Conversion Value
Create Trigger for LinkedIn CAPI Tag
- While still in the tag configuration, click “Triggering”
- Create a new trigger:
- Trigger Type: Custom Event
- Event Name: any of your desired conversion events (e.g., “purchase”, “lead”, “sign_up”)
- This trigger fires on: Some Custom Events
- Add a condition: “Event Name equals [your conversion event]”
- Save your trigger
To track multiple conversion types, you can either:
- Create separate LinkedIn CAPI tags with different triggers for each conversion type
- Use a single tag with multiple triggers
- Use a single tag with a more general trigger and handle event mapping in the tag code
Configure LinkedIn Campaign Manager
- In LinkedIn Campaign Manager, go to Account Assets > Conversions
- Click “Create a conversion”
- Select “Conversions API” as your source
- Name your conversion and select the appropriate category
- In the integration step, select “Google Tag Manager”
- Connect your GTM account if prompted
- Fill in your integration details:
- GA4 measurement ID
- Tagging server URL (your Hardal sGTM endpoint)
- Web GA4 event trigger name
- Complete the setup by associating campaigns with your conversion
Test the Implementation
- Enable Preview mode in both your web and server GTM containers
- Visit your website and trigger a conversion action
- In the web container preview, verify:
- The GA4 event tag fires correctly
- Data is sent to the server container
- In the server container preview, verify:
- The event data is received by the GA4 client
- The LinkedIn CAPI tag fires
- The request to LinkedIn’s API is successful
- In LinkedIn Campaign Manager, use the Test Events tool to verify conversion reception
Event Data Mapping
When sending events from GA4 to LinkedIn CAPI via Hardal’s server-side GTM, use the following event name mapping:
GA4 Event Name | LinkedIn Conversion Type |
---|---|
purchase | Purchase |
generate_lead | Lead |
sign_up | Sign Up |
submit_application | Apply |
request_demo | Request Demo |
download | Download |
add_to_cart | Add to Cart |
Ensure that your GA4 events include these parameters for successful LinkedIn tracking:
- Required: event_name (conversion type)
- Required for user matching: email address (hashed)
- Recommended: value, currency (for purchase events)
- Optional: product details, user data, etc.
Advanced Configuration
Implementing Enhanced Match with Multiple Identifiers
To improve match rates, enhance your LinkedIn CAPI tag with multiple user identifiers:
- LinkedIn Cookie: Add code to capture and send LinkedIn’s first-party cookie
- LinkedIn Click ID: Capture and forward LinkedIn click IDs from ad URLs
- External ID: Include your CRM or user IDs for better cross-channel tracking
Adding Enhanced Conversion Data
For richer conversion information, especially for purchase events, include:
- Transaction ID: Add a unique identifier for each conversion
- Product Details: Include product IDs, categories, and quantities
- Customer Value: Add information about customer lifetime value
Troubleshooting
Events Not Reaching LinkedIn
Events Not Reaching LinkedIn
If your conversion events aren’t showing in LinkedIn:
- Check Server-Side GTM Configuration:
- Verify the GA4 client is properly configured in your server container
- Ensure your server container is properly deployed in Hardal
- Check that the LinkedIn CAPI tag is firing on your desired events
- Verify API Authentication:
- Ensure your LinkedIn access token is valid and correctly formatted
- Check for any API errors in the server container preview mode
- Verify the LinkedIn API endpoint URL is correct
- Data Format Issues:
- Ensure user identifiers (especially email) are properly hashed
- Verify conversion event names match LinkedIn’s expected format
- Check for any required fields that might be missing
Web Container Not Sending Data to Server
Web Container Not Sending Data to Server
If data isn’t flowing from your web container to the server container:
- Check GA4 Configuration:
- Verify the server_container_url parameter is correctly set
- Ensure the URL points to your Hardal sGTM endpoint
- Check that first_party_collection is enabled if sending user data
- Network Issues:
- Look for any CORS errors in browser console
- Verify the server endpoint is accessible from your website
- Check for any SSL/TLS certificate issues
Data Privacy Concerns
Data Privacy Concerns
To ensure proper data privacy compliance:
- Always hash PII before sending:
- Email addresses must be hashed with SHA-256
- Phone numbers should be hashed if used
- External IDs should be hashed if they contain PII
- Consider Consent Management:
- Only send data for users who have consented to tracking
- Implement a consent check in your GA4 event triggers
- Document your data handling processes for compliance