6

This is just an order of operations issue. The documentation is correct, but incomplete. getHeadHtml() will only output head HTML that was queued up for it before the function was actually called. Any head HTML that is queued up after you've called getHeadHtml() will end up getting inserted in the default location - right before the </head> tag. So, ...


2

Craft makes no assumptions on how your site should be built so it's impossible for us to say exactly where to put the pixel code. You would add the code to whichever template you needed it in. This depends entirely on how your site is put together. Oftentimes the <head> portion will be within your main _layout file but that is not necessarily always ...


2

Regarding Problem 1 The Twig function {{ getHeadHtml() }} does only work with JS/CSS that are included before this tag. I had the same problem... you can find the answer/explanation of Brandon Kelly here: getHeadHtml() not outputting CSS included with {% includeCss %} Regarding Problem 2 The {% cache %} does only cache the output HTML, no variables (see ...


1

If you're using SEOmatic for Craft3 it has a setting to add facebook pixel and various other tracking scripts. SEOmatic github


Only top voted, non community-wiki answers of a minimum length are eligible