Add event codes

It looks as though you're viewing this from a region where Pinterest Tag isn't available yet. See where Pinterest Tag is available to Pinterest Business accounts.

Learn more

Event codes let you measure the impact that your Pinterest ads have on certain on-site actions. They’re also necessary to launch campaigns that will automatically optimise 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 must be placed on every page of your website, while event codes only need 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 basket or sign-up 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 baskets.
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.

Add event codes to your website

If your window is still open on Ads Manager from when you copied your base code, click Continue in the bottom right-hand 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 still open, follow the steps below.

  1. Copy the code for the event that you want to add to your website from the list of examples below.
  2. Open the code for the page of your website that you want to track an event on.
  3. 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 that 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)
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 also include event data in the IMG tag 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.

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.

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 constructed successfully 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.

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.

Examples of combined base code and event codes

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

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.

Still need help?
Contact us