Cookie LinkedIn

You only have a LinkedIn cookie and you don't want to use Google Tag manager to install it.

A - locate it on your website

Here is the code that launches LinkedIn

<script type="text/javascript">
_linkedin_partner_id = "2596506";
window._linkedin_data_partner_ids = window._linkedin_data_partner_ids || [];
window._linkedin_data_partner_ids.push(_linkedin_partner_id);
</script><script type="text/javascript">
(function(){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);})();
</script>

<noscript>
<img height="1" width="1" style="display:none;" alt="" src="https://px.ads.linkedin.com/collect/?pid=2596506&fmt=gif" />
</noscript>

B - The LinkedIn function

We'll transform the script and encapsulate it in a function that launches the script.

      window._linkedin_partner_id = "2596506";
      window._linkedin_data_partner_ids = window._linkedin_data_partner_ids || [];
      window._linkedin_data_partner_ids.push(_linkedin_partner_id);

      function launchLinkedIn() {
        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);
      }

C - Integration on your website

You'll now just have to add the previous function and choose to launch the function after user consent.

Great ! Everything works 👌

Last updated