It looks like you're viewing this from a region that Pinterest Tag isn't available in yet. See where Pinterest Tag is available to Pinterest Business accounts. Learn more

Event codes let you measure the impact your Pinterest ads have on certain onsite actions. They’re also necessary to launch campaigns that will automatically optimize specific events such as conversion campaigns or dynamic retargeting ads. Event codes are also necessary for accessing surfaces such as Conversion Insights.

After you add the base code, you can add event codes to track a specific conversion on your website. The base code has to be placed on every page of your website and event codes only have to be placed on pages where you want to track specific conversions. Different event codes are required for different ad campaign objectives. For example, checkout, add to cart or signup are required events for running the Conversion Objective.

Types of event codes

The table below shows the events that you can track with the Pinterest tag. You can use them to create audiences for ads targeting and you can see related paid and organic conversion reporting on Ads Manager. Note: Reporting is not available for user-defined events.

Event Purpose
Checkout Track people who complete transactions.
AddToCart Track people who add items to shopping carts.
PageVisit Track people who view primary pages, such as product pages and article pages.
Signup Track people who sign up for your product or service.
WatchVideo Track people who watch videos.
Lead Track people who show an interest in your product or service.
Search Track people who search on your website for specific products or shop locations.
ViewCategory Track people who view category pages.
Custom Track a custom event. Use this event name to track a special event that you want to include in your conversion reporting.
[User-defined event] Add any additional events that you’ve defined for the purpose of audience targeting. Unique events are not available for conversion reporting. Keep in mind that any spaces in the custom event names passed through the tag will be removed.

You have to add at least one of the following events:

  • Checkout
  • AddToCart
  • Signup
  • Lead

You have to add the following events:

  • Checkout
  • Product ID is being passed through the Checkout event
  • Value and currency are passed through the Checkout tag

We recommend that you add the following events for better performance:

  • PageVisit
  • AddToCart
  • Product ID is being passed through the PageVisit and AddToCart event
Add event codes to your website

If your window is still open on Ads Manager from when you copied your base code, click Continue on the bottom-right corner of the box on your screen to view all of your options and click Copy code beside the event you want to track.

If your window is not open, follow the steps below.

  • Copy the code for the event that you want to add to your website from the list of examples below.
  • Open the code for the page of your website you want to track an event on.
  • Paste the event code between the <head> and </head> tags on your page, after the base code, making sure to replace any example values with the appropriate value for your website. This means the event will fire any time the page is loaded.
  • Note: If an event is triggered only after a user takes a specific action on the page such as clicking a button or submitting a form, make sure that the event code only runs as a result of that action. This requires an understanding of the existing event handlers in your page’s JavaScript code.

    Add event data

    You can provide additional information about an event by attaching an object that contains event data. All event data is available for audience targeting but only value and order_quantity event data are available for paid and organic conversion reporting.

    Event data Sample value Type
    value 100.00 Number (integer or floating point)
    event_id eventId0001

    String (an id string that uniquely identifies the event)

    Note: This id can be sent under any of the following field names, all case-sensitive:

  • eventID
  • event_id
  • eid
  • order_quantity 1 Integer
    order_id 1234OrderID String (order_id is required for conversion analysis reporting) 
    product_name Parker Boots line_items array, string
    product_id 1414 line_items array, string
    product_category Shoes line_items array, string
    product_variant_id 1414-Red line_items array, string
    product_variant Red line_items array, string
    product_price 99.99 Number (integer or floating point), line_items array, string
    product_quantity 1 Integer, line_items array, string
    product_brand Parker line_items array, string
    promo_code WINTER10 String
    property Athleta String
    search_query boots String
    video_title How to style your Parker Boots String
    lead_type Newsletter String
    currency USD

    One of the following: AED, AMD, ARS, AUD, AZN, BAM, BGN, BHD, BMD, BND, BOB, BRL, BSD, CAD, CHF, CLP, CNY, COP, CRC, CZK, DKK, DOP, EGP, EUR, FJD, GBP, GEL, GIP, HKD, HNL, HRK, HUF, IDR, ILS, INR, ISK, JMD, JPY, KGS, KRW, KWD, KZT, MAD, MDL, MOP, MXN, MYR, NOK, NZD, OMR, PAB, PEN, PHP, PKR, PLN, QAR, RON, RSD, RUB, SAR, SEK, SGD, THB, TRY, TWD, UAH, USD, UYU, VND or ZAR.

    Note: when you provide a currency with your tag event, we’ll calculate the exchange rate to match your advertiser account currency.

    Include event data in the IMG tag

    The IMG tag is a piece of code within the Pinterest tag that acts as a backup in case people have disabled JavaScript in their browsers. We recommend that you include event data in the IMG tag too as this enables better user targeting. You can choose to only use the IMG tag and not the JavaScript tag but you will have to remove the <noscript> tags from the code.

     <img height="1" width="1" style="display:none;" alt="" src="https://ct.pinterest.com/v3/?tid=YOUR_TAG_ID&event=checkout&ed[value]=10.00&ed[order_quantity]=2&ed[currency]=USD&ed[event_id]=YOUR_EVENT_ID&ed[line_items][0][product_name]=Parker+Boots&[line_items][0][product_id]='1414'&ed[line_items][0][product_price]=5.00&ed[line_items][0][product_quantity]=1&ed[line_items][1][product_name]=Parker+Sandals&ed[line_items][1][product_id]='ABC'&ed[line_items][1][product_price]=5.00&ed[line_items][1][product_quantity]=1&noscript=1"/>

    Below are examples of every event type so you can copy and paste them directly on your website. Note that you will have to replace example values with a dynamic variable for your website.

    Checkout

     

     <img height="1" width="1" style="display:none;" alt="" src="https://ct.pinterest.com/v3/?tid=YOUR_TAG_ID&event=checkout&ed[event_id]=YOUR_EVENT_ID&ed[value]=10.00&ed[order_quantity]=2&noscript=1" />

    Event data: event_id, value, order_quantity, and currency

    Make sure you enter the correct currency code for your website.

    AddToCart

     <img height="1" width="1" style="display:none;" alt="" src="https://ct.pinterest.com/v3/?tid=YOUR_TAG_ID&event=addtocart&ed[value]=10.00&ed[order_quantity]=2&noscript=1" />

    Event data: value, order_quantity, and currency.

    Make sure to input the correct currency code for your website.

    Pagevisit

     <img height="1" width="1" style="display:none;" alt="" src="https://ct.pinterest.com/v3/?tid=YOUR_TAG_ID&event=pagevisit&noscript=1" />

    Event data: none

    Signup

     <img height="1" width="1" style="display:none;" alt="" src="https://ct.pinterest.com/v3/?tid=YOUR_TAG_ID&event=signup&noscript=1" />
    

    Event data: none

    WatchVideo

     <img height="1" width="1" style="display:none;" alt="" src="https://ct.pinterest.com/v3/?tid=YOUR_TAG_ID&event=watchvideo&ed[video_title]=My+Product+Video+01&noscript=1" />

    Event data: video_title

    Lead

     <img height="1" width="1" style="display:none;" alt="" src="https://ct.pinterest.com/v3/?tid=YOUR_TAG_ID&event=lead&ed[lead_type]=Newsletter&noscript=1" />

    Event data: lead_type

    Search

     <img height="1" width="1" style="display:none;" alt="" src="https://ct.pinterest.com/v3/?tid=YOUR_TAG_ID&event=search&ed[search_query]=horse&noscript=1" />

    Event data: search_query

    ViewCategory

     <img height="1" width="1" style="display:none;" alt="" src="https://ct.pinterest.com/v3/?tid=YOUR_TAG_ID&event=viewcategory&noscript=1" />

    Event data: none

    Custom

    The event type must be called custom—otherwise, the conversions tracked by the tag won't be reported in Ads Manager.

     <img height="1" width="1" style="display:none;" alt="" src="https://ct.pinterest.com/v3/?tid=YOUR_TAG_ID&event=custom&noscript=1" />

    Event data: none

    Pass value and order_quantity event data dynamically

    Value and order_quantity are the two pieces of event data available in paid and organic conversion reporting. If you want to add value and quantity, you can pass them back dynamically. A dynamic value can change depending on the action taken on your site. If you choose to pass back value and order_quantity, this will be unique to your website and how you record sales. The value and quantity of products in each order placed on your website usually varies.

    <script>
     pintrk('track', 'checkout', {
       value: {{Enhanced Transaction Revenue}},
       order_quantity: {{item.quantity}}
     });
    </script>
    <noscript>
     <img height="1" width="1" style="display:none;" alt="" src="https://ct.pinterest.com/v3/?tid=123456789&event=checkout&ed[value]={{Enhanced Transaction Revenue}}&ed[order_quantity]={{item.quantity}}&noscript=1" />
    </noscript>

    Reported value: Dynamic amount purchased with the corresponding Checkout

    Reported quantity: Dynamic quantity purchased with the corresponding Checkout

    Note: The setup of dynamic order quantity and value is unique to your website.

    Pass a JavaScript callback function

    In addition to event data, you can pass a JavaScript callback function as an optional argument to the function pintrk(). This provides additional information if something has gone wrong with your tag which you can check in your developer tool. This callback function runs every time an event tracking call, the function pintrk(), is triggered.

    The callback function takes the following two arguments:

    function(didInit, error) {}
  • didInit: This first argument receives a boolean value, which is set to be true if the event tracking call is successfully constructed and false if an error is detected while making the event tracking call.

  • error: This second argument receives a string, which describes the error when didInit returns false; if didInit is true, this string is undefined.

  • <script>
     pintrk('track', 'checkout', {
       value: 10.00,
       order_quantity: 2,
       currency: 'USD',
       event_id: 'eventId0001',
       line_items: [
         {
           product_name: 'Parker Boots',
           product_id: '1414',
           product_price: 5.00,
           product_quantity: 1
         },
         {
           product_name: 'Parker Sandals'
           product_id: 'ABC',
           product_price: 5.00,
           product_quantity: 1
         }
       ]
     }, function(didInit, error) { if (!didInit) { console.log(error); }
     });
    </script>
    Event code examples

    For conversion tracking and reporting, you must specify one of the nine event types in the event code. You must also replace YOUR_TAG_ID with your Pinterest conversion tag ID. Remember that you can include any combination of event data per event besides what’s shown in the examples below.

    PageVisit

    <script>
     pintrk('track', 'pagevisit', {
       promo_code: 'WINTER10',
       event_id: 'eventId0001',
     });
    </script>

    Signup

    <script>
     pintrk('track', 'signup', {
       lead_type: 'New release promotion'
     });
    </script> 

    Checkout

    <script>
     pintrk('track', 'checkout', {
       value: 116,
       order_quantity: 2,
       currency: 'USD',
       line_items: [
         {
           product_name: 'Pillows (Set of 2)',
           product_id: '11',
           product_price: 48.00,
           product_quantity: 1
         },
         {
           product_name: 'Pillows, Large (Set of 2)',
           product_id: '15',
           product_price: 68.00,
           product_quantity: 1
         },
       ]
     });
    </script>

    WatchVideo

    <script>
     pintrk('track', 'watchvideo', {
       video_title: 'My product video 01'
     });
    </script>

    Lead

    <script>
     pintrk('track', 'lead', {
       lead_type: 'Newsletter'
     });
    </script>

    This section contains an example of every event type in a complete, copyable format that you can place on your site directly. Each example has the event data needed to start tracking activity on your website. Note that you have to replace example values with the appropriate static value or dynamic variable for your website. For example, you will probably want to track order value dynamically because the value of each order placed on your website will vary depending on what a user buys. However, you might assign a static value to the event data lead_type if it is only placed on one specific page.

    Checkout

    <script>
    pintrk('track', 'checkout', { 
       value: 10.00, 
       order_quantity: 2, 
       currency: 'USD', 
       event_id: 'eventId0001',
       product_ids: ['1414', '1415'] }
    );
    </script>
    <noscript>
    <img height="1" width="1" style="display:none;" alt="" src="https://ct.pinterest.com/v3/?tid=YOUR_TAG_ID&event=checkout&ed[value]=10.00&ed[order_quantity]=2&ed[event_id]=eventId0001&noscript=1" />
    </noscript>

    Event data: value, order_quantity, currency, and event_id.

    Make sure to enter the correct currency code for your website.

    AddToCart

    <script>
     pintrk('track', 'addtocart', {
       value: 10.00,
       order_quantity: 1,
       currency: 'USD'
     });
    </script>
    <noscript>
     <img height="1" width="1" style="display:none;" alt="" src="https://ct.pinterest.com/v3/?tid=YOUR_TAG_ID&event=addtocart&ed[value]=10.00&ed[order_quantity]=2&noscript=1" />
    </noscript>

    Event data: value, order_quantity, and currency.

    Make sure to enter the correct currency code for your website.

    Pagevisit

    <script>
     pintrk('track', 'pagevisit');
    </script>
    <noscript>
     <img height="1" width="1" style="display:none;" alt="" src="https://ct.pinterest.com/v3/?tid=YOUR_TAG_ID&event=pagevisit&noscript=1" />
    </noscript>

    Signup

    <script>
     pintrk('track', 'signup');
    </script>
    <noscript>
     <img height="1" width="1" style="display:none;" alt="" src="https://ct.pinterest.com/v3/?tid=YOUR_TAG_ID&event=signup&noscript=1" />
    </noscript>

    WatchVideo

    <script>
     pintrk('track', 'watchvideo', {
       video_title: 'My Product Video 01'
     });
    </script>
    <noscript>
     <img height="1" width="1" style="display:none;" alt="" src="https://ct.pinterest.com/v3/?tid=YOUR_TAG_ID&event=watchvideo&ed[video_title]=My+Product+Video+01&noscript=1" />
    </noscript>

    Event data: Video_title

    Lead

    <script>
     pintrk('track', 'lead', {
       lead_type: 'Newsletter'
     });
    </script>
    <noscript>
     <img height="1" width="1" style="display:none;" alt="" src="https://ct.pinterest.com/v3/?tid=YOUR_TAG_ID&event=lead&ed[lead_type]=Newsletter&noscript=1" />
    </noscript>

    Event data: lead_type

    Search

    <script>
     pintrk('track', 'search', {
       search_query: 'horse'
     });
    </script>
    <noscript>
     <img height="1" width="1" style="display:none;" alt="" src="https://ct.pinterest.com/v3/?tid=YOUR_TAG_ID&event=search&ed[search_query]=horse&noscript=1" />
    </noscript>
    

    Event data: search_query

    ViewCategory

    <script>
     pintrk('track', 'viewcategory');
    </script>
    <noscript>
     <img height="1" width="1" style="display:none;" alt="" src="https://ct.pinterest.com/v3/?tid=YOUR_TAG_ID&event=viewcategory&noscript=1" />
    </noscript>

    Custom

    The event type must be called custom otherwise, the conversions tracked by the tag will not be reported in Ads Manager.

    <script>
     pintrk('track', 'custom');
    </script>
    <noscript>
     <img height="1" width="1" style="display:none;" alt="" src="https://ct.pinterest.com/v3/?tid=YOUR_TAG_ID&event=custom&noscript=1" />
    </noscript>

     

    Examples of combined base code and event codes

    Here are some examples of base codes combined with event codes. Remember to confirm the event code is placed after the base code on your website.

    Example conversion tag ID: 123456789 (replace with your Pinterest conversion tag ID)
    Example event code: PageVisit

    <head>
     <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', '123456789'); pintrk('page');
     </script>
     <noscript>
       <img height="1" width="1" style="display:none;" alt="" src="https://ct.pinterest.com/v3/?tid=123456789&noscript=1" />
     </noscript>
     <script>
       pintrk('track', 'pagevisit');
     </script>
     <noscript>
       <img height="1" width="1" style="display:none;" alt="" src="https://ct.pinterest.com/v3/?tid=123456789&event=pagevisit&noscript=1" />
     </noscript>
    </head>
    

    Example conversion tag ID: 123456789 (replace with your Pinterest conversion tag ID)
    Example event codes: PageVisit and AddToCart

    <head>
     <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', '123456789'); pintrk('page');
     </script>
     <noscript>
       <img height="1" width="1" style="display:none;" alt="" src="https://ct.pinterest.com/v3/?tid=123456789&noscript=1" />
     </noscript>
     <script>
       pintrk('track', 'pagevisit');
       pintrk('track', 'addtocart');
     </script>
     <noscript>
       <img height="1" width="1" style="display:none;" alt="" src="https://ct.pinterest.com/v3/?tid=123456789&event=pagevisit&noscript=1" />
       <img height="1" width="1" style="display:none;" alt="" src="https://ct.pinterest.com/v3/?tid=123456789&event=addtocart&noscript=1" />
     </noscript>
    </head>
    What’s the next step?

    Learn more about tag parameters and cookies or enable optional Enhanced Match. If you do not want to do either, verify your Pinterest tag.

    End of Other articles Links
    Still need help? Contact us
    User feedback
    Was this article helpful?

    collection_fields

    How can we make this article better?