1. Home
  2. Code Snippets for LinkedIn Pixel & On Click Conversion Event Tracking

Code Snippets for LinkedIn Pixel & On Click Conversion Event Tracking

The following is an example of how customers can add their LinkedIn Insight Tags to their PathFactory instance. This lightweight JavaScript can be used to track conversions, retarget website visitors, and unlock additional insights about visitors interacting with your content. lightweight JavaScript tag that can be used to track conversions.

This script utilizes LinkedIn’s general Insight Tag, and leverages PathFactory’s Dispatch Jukebox Events which can be used to trigger other functions in PathFactory. In particular, the ‘click_content’’ event is being used to fire a conversion event. This includes clicking on the asset link in a Flow layout and clicking on the Next or Previous promoters of a track. The code can be modified to also use submit_external_form to trigger the same code when a CUSTOM HTML or an EXTERNAL URL form is submitted.

To see more examples of code snippets, read Frequently Used External Code Snippets to Personalize Your PathFactory Experiences.

Where to place the script?

This script can be added through your External Code library and you can find a step by step guide on how to do so in our article Using External Code. The location can be set to either of the ‘Head Tag’ or either of the ‘Body Tag’ options. This can be applied globally to any PathFactory instance.

Important: All instances of multiple xxxxx are underlined in the code in the section below. These are the IDs that you will need to modify to match your LinkedIn configuration.

Code Snippet

<!– Beginning of Linkedin’s Insight Tag –> 

<script type=”text/javascript”>

_linkedin_partner_id = “xxxxx“;

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(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=xxxxx&fmt=gif” />

</noscript>
<!– end of Linkedin’s Insight Tag –> 

<!– Beginning of Linkedin’s conversion event based on PathFactory’s click_content dispatch event explained above–> 

<script>

handleJukeboxDispatchedEvents = event => {

        switch (event.detail.eventName) {

          case “click_content:”

            window.lintrk(‘track’, { conversion_id: xxxxxxx });

            break;

        }

      };

      window.addEventListener(“pf_event”, this.handleJukeboxDispatchedEvents, false);

</script>

<!– Beginning of Linkedin’s conversion event based on PathFactory’s external form explained above–> 

<script>

handleJukeboxDispatchedEvents = event => {

        switch (event.detail.eventName) {

          case “submit_external_form:”

            window.lintrk(‘track’, { conversion_id: xxxxxxx });

            break;

        }

      };

      window.addEventListener(“pf_event”, this.handleJukeboxDispatchedEvents, false);

</script>

Updated on July 27, 2023

Was this article helpful?

Need Support?
Can't find the answer you're looking for? Don't worry we're here to help!
CONTACT SUPPORT