Adding Script below the Header (for Facebook Pixel Event)

Hey all, I am trying to add some <script>...</script> code directly beneath the </head> tag. Any suggestions please?

Specifically, I am trying to add Facebook Pixel Event code, and it’s required that this code goes just below the </head> tag: https://developers.facebook.com/docs/ads-for-websites/pixel-events#setup

Thanks!

Does adding an HTML block as the first item on the page work? That way it would be directly below the /head.

Thanks @cowontherun - however, if you add an element there, it actually appears in the <body> after several lines of other bubble code (please see section highlighted below):

image

Are you sure it’s supposed to be below the head? Normally they go in the head as states here:

In fact on the page you link to it states “In the page’s HTML, add the code to your website pages before the ending /head tag”

So all you need to do is go to Settings > SEO tab and add it there.

var getUpThere; 
getUpThere = $('<script id="PlugBubble"></script>'); 
$('head').first().append(getUpThere); 

image

oh sorry beneth…

var getUpThere; 
getUpThere = $('<script id="PlugBubble"></script>'); 
$('body').first().prepend(getUpThere);
1 Like

Thanks @jarrad I’ll try that out.

I am also experimenting with loading the FB code via Google Tag Manager, which seems to work really well too.

Hi Jarrad, Im having the same problem with the facebook pixel events. Where would you place this code to be able to insert the script right beneath the body?