TLDR: LinkedIn Insight Tag has no built-in consent API. The only compliant approach is blocking it until consent. GetCookies handles this with a simple data attribute.
Read full summary
LinkedIn Insight Tag powers conversion tracking for LinkedIn Ads. Unlike Meta and TikTok, it doesn't have a consent API—you must prevent loading entirely until consent. This guide shows how to do it properly.
Summary by Claude AI
The LinkedIn Consent Problem
Meta Pixel has fbq('consent', 'grant').
TikTok Pixel has ttq.enableCookie().
LinkedIn Insight Tag has... nothing.
LinkedIn's tag doesn't include a consent API. Once it loads, it collects data. The only GDPR-compliant approach is preventing it from loading until consent.
This is actually simpler to implement, but requires a different pattern.
The GetCookies Solution
Use the data-cookieconsent attribute to block the script until marketing consent:
<head>
<!-- GetCookies -->
<script src="https://getcookies.co/api/v1/widget/loader.js"
data-domain-id="YOUR_DOMAIN_ID"
async></script>
<!-- LinkedIn Insight Tag - only after marketing consent -->
<script type="text/plain" data-cookieconsent="marketing">
_linkedin_partner_id = "YOUR_PARTNER_ID";
window._linkedin_data_partner_ids = window._linkedin_data_partner_ids || [];
window._linkedin_data_partner_ids.push(_linkedin_partner_id);
(function(l) {
if (!l){window.lintrk=function(a,b){window.lintrk.q.push([a,b])};
window.lintrk.q=[]}
var s = document.getElementsByTagName("script")[0];
var b = document.createElement("script");
b.type = "text/javascript";b.async = true;
b.src = "https://snap.licdn.com/li.lms-analytics/insight.min.js";
s.parentNode.insertBefore(b, s);
})(window.lintrk);
</script>
<noscript>
<img height="1" width="1" style="display:none;" alt=""
src="https://px.ads.linkedin.com/collect/?pid=YOUR_PARTNER_ID&fmt=gif" />
</noscript>
</head>
The type="text/plain" prevents execution. GetCookies changes it to text/javascript after marketing consent.
How It Works
- User loads your page
- GetCookies shows consent banner
- LinkedIn tag is blocked (type="text/plain")
- User accepts marketing cookies
- GetCookies activates the script (type="text/javascript")
- LinkedIn tag loads and starts tracking
If user rejects marketing cookies, the tag never loads. Full compliance.
Dynamic Loading Pattern
For more control, load the tag programmatically:
window.addEventListener('getcookies:consent', (e) => {
if (e.detail.marketing && !window.linkedInLoaded) {
loadLinkedInTag();
window.linkedInLoaded = true;
}
});
function loadLinkedInTag() {
_linkedin_partner_id = "YOUR_PARTNER_ID";
window._linkedin_data_partner_ids = window._linkedin_data_partner_ids || [];
window._linkedin_data_partner_ids.push(_linkedin_partner_id);
var s = document.getElementsByTagName("script")[0];
var b = document.createElement("script");
b.type = "text/javascript";
b.async = true;
b.src = "https://snap.licdn.com/li.lms-analytics/insight.min.js";
s.parentNode.insertBefore(b, s);
}
Conversion Tracking
After consent, track conversions:
// Standard conversion
window.lintrk('track', { conversion_id: 123456 });
LinkedIn Conversions API (Server-Side)
For better attribution, use server-side tracking:
import requests
url = "https://api.linkedin.com/rest/conversionEvents"
headers = {
"Authorization": "Bearer YOUR_ACCESS_TOKEN",
"LinkedIn-Version": "202401",
"Content-Type": "application/json"
}
payload = {
"conversion": "urn:lla:llaPartnerConversion:123456",
"conversionHappenedAt": 1640000000000,
"user": {
"userIds": [{
"idType": "SHA256_EMAIL",
"idValue": "hashed_email"
}]
}
}
response = requests.post(url, headers=headers, json=payload)
Server-side events can run regardless of browser consent but should respect user preferences where possible.
Testing
- Install LinkedIn Insight Tag Helper extension
- Load site in incognito
- Before consent: Tag should NOT be in Network tab
- Accept marketing cookies
- Refresh: Tag should appear and fire
The Bottom Line
LinkedIn Insight Tag doesn't have a consent API. The compliant approach is simple: don't load it until consent.
GetCookies makes this trivial with the data-cookieconsent attribute. One attribute change. Full compliance.
Ready to make your LinkedIn tracking compliant?