There are many plugins that will let you add Facebook, Google Analytics, Google Tag Manager or any other data collector pixel to your website with ease.

But instlling a plugin for every small task will cause your website become heavy very quickly and that’s something you want to prevent.

With this code you can add ANY pixel code you need to your website’s <head> tag.

Place it in your theme’s functions.php file:

add_action( 'wp_head', 'add_code_to_head', 200 );
function add_code_to_head(){
	?>

	// PASTE YOUR CODES BELOW THIS LINE

    <?php
}

If you want to add it into your footer, just use:

add_action( 'wp_footer', 'add_code_to_footer', 200 );
function add_code_to_footer(){
	?>

	// PASTE YOUR CODES BELOW THIS LINE

    <?php
}

How useful was this post?

Click on a star to rate it!

Average rating / 5. Vote count:

We are sorry that this post was not useful for you!

Let us improve this post!