Fire the LinkedIn Insight Tag only after visitors accept targeting cookies
Tag every script of the LinkedIn Insight Tag with targeting, and by default TermsFeed Free Cookie Consent holds the Insight Tag until the visitor accepts advertising cookies. Before the answer, by default, no request reaches LinkedIn and no LinkedIn cookie is stored. The moment the visitor accepts, the Insight Tag runs on the same page, with no reload, and records the page view.
The Insight Tag identifies visitors for conversion tracking, retargeting, and audience reports, so it needs consent first for visitors in the EU and the UK. The setup takes about 10 minutes. Have the Cookie Consent code from the TermsFeed generator on your pages and access to LinkedIn Campaign Manager before you start.
Tag the LinkedIn Insight Tag with targeting
LinkedIn shows the Insight Tag code only in Campaign Manager and asks you to copy the full code. Tagging changes the opening <script> tags and removes the <noscript> image, and the JavaScript stays as copied.
Copy the code from Campaign Manager, tag it, and paste it into your pages. Compare the Campaign Manager menu names with the LinkedIn help article Add the LinkedIn Insight Tag to your website.
- Go to your ad account in Campaign Manager, click Measure in the left menu, then click Signals manager.
- Click Insight Tag, then open the I will install the tag myself dropdown, and copy the code.
- Replace each opening
<script>tag of the code with<script type="text/plain" data-cookie-consent="targeting">, and keep each closing</script>tag and the JavaScript between the tags unchanged. - Delete any
<noscript>element in the code. - Paste the result into the pages of your domain. LinkedIn recommends the spot right before the closing
</body>tag in the global footer of your site.
The tagged code runs from any place in the page markup, because run() starts on DOMContentLoaded. Keep the scripts in the order LinkedIn gives them, because the tagged scripts of one category run in page order. The script that sets the partner ID then runs before the script that loads insight.min.js. Read how tagged scripts run, and which attributes they keep, in Block Scripts Until Consent.
Where the LinkedIn conversion scripts go
Campaign Manager gives an event-specific conversion as a lintrk('track', ...) call or as an image pixel. Put a call that runs on page load, such as on a thank-you page, in a script tagged targeting below the Insight Tag scripts, so it runs after them. Call lintrk from a click handler only when window.lintrk exists, because the tagged Insight Tag defines it once the visitor accepts. Leave the image pixel out, because Cookie Consent holds only scripts.
How to verify that the LinkedIn Insight Tag waits for consent
The checks assume express consent with page_load_consent_levels left out or at the generator value ["strictly-necessary"], and the "I decline" button shown. Publish the change and clear any page cache before the check. Watch the Network tab for LinkedIn requests before and after the answer. Close every private window, then start the check in a new one, where no saved answer hides the consent banner.
- Open your site in that window of Chrome, open DevTools, and select the Network tab.
- Type
licdnin the filter box and reload. No request appears while the consent banner shows. Repeat with the filterlinkedin. In the Application tab, under Cookies, no LinkedIn cookie is listed for your domain. - Clear the filter and click the "I agree" button. Requests to
snap.licdn.comandpx.ads.linkedin.comappear. LinkedIn lists both hosts for the Insight Tag in Troubleshoot the LinkedIn Insight Tag. - Select the Application tab, open Cookies, and check that LinkedIn cookies, such as
ln_or, are listed now on your domain.li_fat_idappears only after a visit from a click on a LinkedIn ad. - Close every private window and open a new one. Open DevTools, type
licdnin the Network filter, load your site, and click the "I decline" button. The filter stays empty, and so doeslinkedinwhen you switch to it. No LinkedIn cookie appears.
Cookies the LinkedIn Insight Tag sets
The Insight Tag stores cookies on your domain and on linkedin.com, including these from the LinkedIn cookie table. List them in your Cookies Policy under targeting cookies.
| Cookie | Domain | Lifetime |
|---|---|---|
li_fat_id |
Your domain | 30 days |
ln_or |
Your domain | 1 day |
bcookie |
linkedin.com |
1 year |
lidc |
linkedin.com |
1 day |
UserMatchHistory |
linkedin.com |
30 days |
li_sugr |
linkedin.com |
90 days |
Common mistakes with the LinkedIn Insight Tag
Check every page that carries the Insight Tag for each mistake. A LinkedIn request in your check before the answer comes from code that Cookie Consent does not hold, such as an untagged script or a copy another tool adds.
- A
<noscript>image stays in the page. A visitor with JavaScript turned off never sees the consent banner, because Cookie Consent is a script, and the image sends a request topx.ads.linkedin.comwithout consent. Your own check with JavaScript on never shows that request. Search the page source of each page for<noscript>near the Insight Tag, and delete the whole<noscript>element. - Only one script of the Insight Tag is tagged. An untagged script that loads
insight.min.jssends a request tosnap.licdn.combefore the answer, while the script that sets the partner ID sends nothing by itself. Search the page source for each script of the Insight Tag, and check that it carriestype="text/plain". Tag every script of the code. - A plugin, an app, or a tag manager adds the Insight Tag. That copy runs outside Cookie Consent, which holds only tagged scripts in your own markup. The
licdnfilter then shows a request before the answer, though your own copy is tagged. Remove the Insight Tag from that plugin, app, or tag manager, and keep the copy you tagged. - A conversion script stays untagged. The script calls
lintrkbefore the tagged Insight Tag defines the function, so the Console tab shows an error and LinkedIn does not record a conversion. Search the page source for each conversion script and itsdata-cookie-consentattribute, and tag every one withtargeting. - The Insight Tag is tagged with
tracking. The Insight Tag serves advertising, but atrackingtag runs it for a visitor who accepts tracking cookies and refuses targeting cookies. Look fordata-cookie-consent="tracking"on the Insight Tag scripts, and change it totargeting. - You expect a withdrawal to delete LinkedIn cookies. Cookie Consent does not delete cookies set by LinkedIn, so the Application tab still lists the LinkedIn cookies on your domain after the withdrawal. The Insight Tag itself stays held from the next page load on. Delete the LinkedIn cookies on your domain from a callback with the pattern in Rejecting Does Not Delete Cookies Already Set.
Events your server sends to the LinkedIn Conversions API never pass through the consent banner. Read why server-side event sending bypasses the consent banner in Vendor Recipes for Free Cookie Consent.