LinkedIn insight tag

Hi there, what’s the best method of inserting the LinkedIn Insight Tag into the themes function.php file.

Linkedin say this “Add the JavaScript code to every page on your domain, preferably right before the end of the tag in the global footer.”

I asked a similar question recently regarding inserting another script for Ontraport. I have literally taken the same code, which you provided in your response, and removed any mention of ‘ontraport’ and instead inserted the LinkedIn script. I have therefore done this:

// Add Linkedin insight tag to every page
// =============================================================================
add_action( 'wp_footer', 'linkedin_script', 999 );
function linkedin_script() { ?>

I ADDED THE LINKEDIN SCRIPT HERE

<?php
}
// =============================================================================

Is this a suitable method?

So for example this bit of code ‘add_action( ‘wp_footer’, ‘linkedin_script’, 999 );’

I don’t even know what the ‘999’ bit of code means but I literally copy and pasted from the previous response. Same goes for the bit of code where it says ‘linkedin_script’ I literally just wrote ‘linkedin’ where as before (from my previous question) it said ‘ontraport_script’.

Is this all fine?

Thanks

Lewis

Hi Lewis,

Thank you for writing in! Yes, you can do that! The 999 is optional, it’s a priority number, the lower the number the earlier the function will be executed when the page load.

Let us know how it goes,
Cheers!

Hi Friech

Thanks for you reply

If there are 2 codes with a priority of 999, which will get loaded first? Is it the one that appears first in the code?

Thanks

Lewis

Hi Lewis,

The PHP code will run from the top to bottom.

Here is the example:

// this action will executive first
// =============================================================================
add_action( 'wp_footer', 'linkedin_script_first', 999 );
function linkedin_script_first() { ?>

I ADDED THE LINKEDIN SCRIPT HERE

<?php
}
// =============================================================================

// this action will executive then
// =============================================================================
add_action( 'wp_footer', 'linkedin_script_second', 999 );
function linkedin_script_second() { ?>

I ADDED THE LINKEDIN SCRIPT HERE

<?php
}
// =============================================================================

Hope it’s clear :slight_smile:

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.