<p>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. </p>

<p>You would add the code to whichever template you needed it in. This depends entirely on how your site is put together.</p>

<p>Oftentimes the <code>&lt;head&gt;</code> portion will be within your main <code>_layout</code> file but that is not necessarily always the case. This file can also be anywhere within your templates directory.</p>

<p>For Craft 2, look in your <code>/craft/templates</code> directory
For Craft 3, look in your <code>/templates</code> directory</p>

CC BY-SA 4.0
2018-11-14T20:44:16.943Z
2018-11-15T10:52:50.420Z
2018-11-15T10:52:50.420Z
foamcow
<p>If you're using SEOmatic for Craft3 it has a setting to add facebook pixel and various other tracking scripts.</p>

<p><a href="https://github.com/nystudio107/seomatic" rel="nofollow noreferrer">SEOmatic github</a></p>

CC BY-SA 4.0
2018-11-16T00:25:50.637Z
Thanks Steven, if I don't have that plugin, is there any way to do it for free?
Jordan Hayes
CC BY-SA 4.0
2018-11-16T13:01:23.017Z
If you don't use that plugin you can use the answer foamcow gave and manually insert it in your template code.
Steven Vandemoortele
CC BY-SA 4.0
2018-11-15T09:41:09.397Z
2018-11-15T09:41:09.397Z
Steven Vandemoortele
<p>How do I add the html code to the head of my website in Craft CMS? </p>

<p>Do I need to install a plugin, or is there somewhere I can access the code?</p>

<getheadhtml><headers>
How to add Facebook pixel code to my website
# How to add Facebook pixel code to my website

(Asked by: username_0 on 2018-11-14)

How do I add the html code to the head of my website in Craft CMS?

Do I need to install a plugin, or is there somewhere I can access the code?

**Tags:** getheadhtml, headers

---

## 2 answers

### Answer by username_1 on 2018-11-14. Score: 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  portion will be within your main `_layout` file but that is not necessarily always the case. This file can also be anywhere within your templates directory.

For Craft 2, look in your `/craft/templates` directory
For Craft 3, look in your `/templates` directory


---

### Answer by username_2 on 2018-11-15. Score: 1

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

[SEOmatic github](https://github.com/nystudio107/seomatic)

> **Comments:**
> **username_0**: Thanks Steven, if I don't have that plugin, is there any way to do it for free?  
> **username_2**: If you don't use that plugin you can use the answer foamcow gave and manually insert it in your template code.  

---

