Base code

The base code is the primary code for Pinterest Tag. It needs to be added to every page of your website in order for any event codes to function and to build audience data from the traffic on your site. 

You can generate your individual base code in the Conversions page in Ads Manager, which contains your unique tag ID. You only need to generate one unique tag ID. Once generated, place your base code on every page of your website to track conversions and build audiences across your entire website.

Placement

It’s important to place the base code so that it loads first on the page. This is usually in the <head> section of your website’s HTML, but it may be different depending on your website. The base code needs to fire before the event code, so you need to place it so that it will fire before any event code you plan to implement.

Example

Below is an example base code, but remember that you should retrieve your personalised base code from your profile in Ads Manager or the API. We do not recommend copying and pasting from this guide. When you obtain your base code from Ads Manager, it will have your unique Pinterest Tag ID inserted in the proper locations of the code, where you see YOUR_TAG_ID in the code below.

<head>
 <!-- Pinterest Pixel Base Code -->
 <script type="text/javascript">
   !function(e){if(!window.pintrk){window.pintrk=function(){window.pintrk.queue.push(
     Array.prototype.slice.call(arguments))};var
     n=window.pintrk;n.queue=[],n.version="3.0";var
     t=document.createElement("script");t.async=!0,t.src=e;var
     r=document.getElementsByTagName("script")[0];r.parentNode.insertBefore(t,r)}}("https://s.pinimg.com/ct/core.js");
   pintrk('load', 'YOUR_TAG_ID');
   pintrk('page');
 </script>
 <noscript>
   <img height="1" width="1" style="display:none;" alt="" src="https://ct.pinterest.com/v3/?tid=YOUR_TAG_ID&event=init&noscript=1" />
 </noscript>
 <!-- End Pinterest Pixel Base Code -->
</head>

First-party cookies

The Pinterest Tag creates and accesses cookies in a first party context on your site domain, providing better visibility of the Pinterest traffic on your site.

You always have the option to delete first-party cookies by updating your base code to set the fp_cookie parameter to false:

<script>
 pintrk('load', '<tag_id>', {
   'fp_cookie': false,
   'em': '<email address>',
 });
</script>

Next steps

Once you’ve finished adding the base code, you can add an event code.

Still need help?
Contact us