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 necessary to launch campaigns that will automatically optimize specific events such as conversion campaigns or dynamic retargeting ads. You’ll also need event codes to access conversion insights and join the Verified Merchant Program.

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 running different ad campaigns and accessing certain features.

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.
Required and recommended events for ad campaigns

There are required and recommended events depending on what ads campaign you decide to run.

Campaign type Required events Recommended events Required event data Recommended event data
Brand awareness None
  • Pagevisit
  • Checkout
  • Addtocart
  • Lead
  • Signup
None Enhanced match
Catalog sales
  • Pagevisit
  • Addtocart
  • Checkout
  • Signup
  • Lead
  • Product ID
  • Order ID
  • Value
  • Currency (required for addtocart and checkout)
  • Product category
  • Enhanced match
Consideration None
  • Pagevisit
  • Checkout
  • Addtocart
  • Lead
  • Signup
None Enhanced match
Conversions

At least one of the following:

  • Signup
  • Lead
  • Addtocart
  • Checkout
  • Product ID
  • Order ID
  • Value
  • Enhanced match
None
  • Product category
  • Currency
  • Enhanced match
Video views None None None Enhanced match
Required and recommended events for features

There are required and recommended events depending on what features you want to use.

Feature Required events Recommended events Required event data Recommended event data
Conversion insights
  • Pagevisit
  • Addtocart
  • Checkout
None Currency None
Verified Merchant Program (VMP)
  • Pagevisit
  • Addtocart
  • Checkout
None Currency None
Dynamic retargeting
  • Pagevisit
  • Addtocart
  • Checkout
None
  • Product ID
  • Value
  • Currency
None
Add event codes to your website

If you’ve decided to use manual set-up, you’ll have to add event codes to your website yourself. The steps below are for people who are using the manual set-up option.

  1. Log in to your Pinterest business account from your desktop.
  2. Click the hamburger icon at the top-left of the page
  3. Under Business, click Conversions
  4. Click Get started.
  5. Select Pinterest Tag only, then click Continue.
  6. Click Skip at the bottom-right of your screen.
  7. Click Skip to manual setup.
  8. Copy the base code, then click Continue.
  9. Choose whether to enable automatic enhanced match, then click Continue.
  10. Click Copy code below the gray box, next to the event code you want to add.
  11. Open the code for the page of your website you want to track an event on.
  12. Paste the event code on the page where the event should occur, 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.
  13. Click Done.

Note: If an event is triggered only after someone 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 without the JavaScript tag but you’ll have to remove the <noscript> tags from the code.

    Below are examples of every event type so you can copy and paste them directly on your website. Note that you'll 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 you enter 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.

    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'll probably want to track order value dynamically because the value of each order placed on your website will vary depending on what someone 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', {
    event_id: 'eventId0001',
    value: 100,
    order_quantity: 1,
    currency: 'USD',
    order_id: 'X-15148',
    promo_code: 'WINTER10',
    property: 'Athleta',
    search_query: 'boots',
    video_title: 'How to style your Parker Boots',
    lead_type: 'Newsletter',
    line_items: [
    {
    product_name: 'Parker Boots',
    product_id: '1414',
    product_category: 'Shoes',
    product_variant_id: '1414-Red',
    product_variant: 'Red',
    product_price: 99.99,
    product_quantity: 1,
    product_brand: 'Parker'
    }
    ]
    });
    </script>

    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', {
    event_id: 'eventId0001',
    value: 100,
    order_quantity: 1,
    currency: 'USD',
    order_id: 'X-15148',
    promo_code: 'WINTER10',
    property: 'Athleta',
    search_query: 'boots',
    video_title: 'How to style your Parker Boots',
    lead_type: 'Newsletter',
    line_items: [
    {
    product_name: 'Parker Boots',
    product_id: '1414',
    product_category: 'Shoes',
    product_variant_id: '1414-Red',
    product_variant: 'Red',
    product_price: 99.99,
    product_quantity: 1,
    product_brand: 'Parker'
    }
    ]
    });
    </script>

    Event data: value, order_quantity, and currency.

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

    Pagevisit

    <script>
    pintrk('track', 'pagevisit', {
    event_id: 'eventId0001',
    value: 100,
    order_quantity: 1,
    currency: 'USD',
    order_id: 'X-15148',
    promo_code: 'WINTER10',
    property: 'Athleta',
    search_query: 'boots',
    video_title: 'How to style your Parker Boots',
    lead_type: 'Newsletter',
    line_items: [
    {
    product_name: 'Parker Boots',
    product_id: '1414',
    product_category: 'Shoes',
    product_variant_id: '1414-Red',
    product_variant: 'Red',
    product_price: 99.99,
    product_quantity: 1,
    product_brand: 'Parker'
    }
    ]
    });
    </script>

    Signup

    <script>
    pintrk('track', 'signup', {
    event_id: 'eventId0001',
    value: 100,
    order_quantity: 1,
    currency: 'USD',
    order_id: 'X-15148',
    promo_code: 'WINTER10',
    property: 'Athleta',
    search_query: 'boots',
    video_title: 'How to style your Parker Boots',
    lead_type: 'Newsletter',
    line_items: [
    {
    product_name: 'Parker Boots',
    product_id: '1414',
    product_category: 'Shoes',
    product_variant_id: '1414-Red',
    product_variant: 'Red',
    product_price: 99.99,
    product_quantity: 1,
    product_brand: 'Parker'
    }
    ]
    });
    </script>

    Watchvideo

    <script>
    pintrk('track', 'watchvideo', {
    event_id: 'eventId0001',
    value: 100,
    order_quantity: 1,
    currency: 'USD',
    order_id: 'X-15148',
    promo_code: 'WINTER10',
    property: 'Athleta',
    search_query: 'boots',
    video_title: 'How to style your Parker Boots',
    lead_type: 'Newsletter',
    line_items: [
    {
    product_name: 'Parker Boots',
    product_id: '1414',
    product_category: 'Shoes',
    product_variant_id: '1414-Red',
    product_variant: 'Red',
    product_price: 99.99,
    product_quantity: 1,
    product_brand: 'Parker'
    }
    ]
    });
    </script>

    Event data:Video_title

    Lead

    <script>
    pintrk('track', 'lead', {
    event_id: 'eventId0001',
    value: 100,
    order_quantity: 1,
    currency: 'USD',
    order_id: 'X-15148',
    promo_code: 'WINTER10',
    property: 'Athleta',
    search_query: 'boots',
    video_title: 'How to style your Parker Boots',
    lead_type: 'Newsletter',
    line_items: [
    {
    product_name: 'Parker Boots',
    product_id: '1414',
    product_category: 'Shoes',
    product_variant_id: '1414-Red',
    product_variant: 'Red',
    product_price: 99.99,
    product_quantity: 1,
    product_brand: 'Parker'
    }
    ]
    });
    </script>

    Event data: lead_type

    Search

    <script>
    pintrk('track', 'search', {
    event_id: 'eventId0001',
    value: 100,
    order_quantity: 1,
    currency: 'USD',
    order_id: 'X-15148',
    promo_code: 'WINTER10',
    property: 'Athleta',
    search_query: 'boots',
    video_title: 'How to style your Parker Boots',
    lead_type: 'Newsletter',
    line_items: [
    {
    product_name: 'Parker Boots',
    product_id: '1414',
    product_category: 'Shoes',
    product_variant_id: '1414-Red',
    product_variant: 'Red',
    product_price: 99.99,
    product_quantity: 1,
    product_brand: 'Parker'
    }
    ]
    });
    </script>
    

    Event data: search_query

    Viewcategory

    <script>
    pintrk('track', 'viewcategory', {
    event_id: 'eventId0001',
    value: 100,
    order_quantity: 1,
    currency: 'USD',
    order_id: 'X-15148',
    promo_code: 'WINTER10',
    property: 'Athleta',
    search_query: 'boots',
    video_title: 'How to style your Parker Boots',
    lead_type: 'Newsletter',
    line_items: [
    {
    product_name: 'Parker Boots',
    product_id: '1414',
    product_category: 'Shoes',
    product_variant_id: '1414-Red',
    product_variant: 'Red',
    product_price: 99.99,
    product_quantity: 1,
    product_brand: 'Parker'
    }
    ]
    });
    </script>

    User-defined events

    <script>
    pintrk('track', 'user_defined_event_name', {
    event_id: 'eventId0001',
    value: 100,
    order_quantity: 1,
    currency: 'USD',
    order_id: 'X-15148',
    promo_code: 'WINTER10',
    property: 'Athleta',
    search_query: 'boots',
    video_title: 'How to style your Parker Boots',
    lead_type: 'Newsletter',
    line_items: [
    {
    product_name: 'Parker Boots',
    product_id: '1414',
    product_category: 'Shoes',
    product_variant_id: '1414-Red',
    product_variant: 'Red',
    product_price: 99.99,
    product_quantity: 1,
    product_brand: 'Parker'
    }
    ]
    });
    </script>

    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', {
    event_id: 'eventId0001',
    value: 100,
    order_quantity: 1,
    currency: 'USD',
    order_id: 'X-15148',
    promo_code: 'WINTER10',
    property: 'Athleta',
    search_query: 'boots',
    video_title: 'How to style your Parker Boots',
    lead_type: 'Newsletter',
    line_items: [
    {
    product_name: 'Parker Boots',
    product_id: '1414',
    product_category: 'Shoes',
    product_variant_id: '1414-Red',
    product_variant: 'Red',
    product_price: 99.99,
    product_quantity: 1,
    product_brand: 'Parker'
    }
    ]
    });
    </script>
    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 next?

    Verify the Pinterest tag to make sure everything is functioning correctly.

    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?