Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

Pawel2014 on "A part of Facebook pixel code is autamagically wrapped by quotation marks"

$
0
0

Hi,

I have inserted Facebook pixel code into <head> section of every page, post, etc. of my web site using a pretty simple function located in functions.php of my child theme.
The function looks like this:

function my_fb_pixel() {
    echo "<script>(function() {
…
  }
})();
window._fbq = window._fbq || [];
window._fbq.push(['track', '6022646741664', {'value':'0.00','currency':'PLN'}]);
</script>";
echo '<noscript><img height="1" width="1" alt="" style="display:none" src="https://www.facebook.com/tr?ev=6022646741664&cd[value]=0.00&cd[currency]=PLN&noscript=1" /></noscript>';
}
add_action('wp_head', 'my_fb_pixel ');

Everything goes to the <head> section as intended, but the part within <noscript> tags is wrapped by quotation marks and this piece of code looks as follows:

<noscript>
“<img height="1" width="1" alt="" style="display:none" src="https://www.facebook.com/tr?ev=6022646741664&cd[value]=0.00&cd[currency]=PLN&noscript=1" />”
</noscript>

which is incorrect in my opinion. I’d would rather expect getting the code as it was used in echo command. The same happens when Facebook Pixel plugins place the pixel code.

I guess that this part won't be processed correctly by browsers and pixel information will be missing.

Any ideas how to fix it?


Viewing all articles
Browse latest Browse all 8245

Trending Articles