Event code

After you add the base code, you can add an event code to track a specific conversion event on your website.

The table below shows the events that you can track with the Pinterest tag, and whether they include audience creation and conversion reporting.

Event

Purpose

Audience creation

Conversion reporting

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 perform searches on your website to look 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 aren’t available for conversion reporting. Bear in mind that whitespace will be trimmed from raw event names passed through the tag

 

Placement

Both the base code and event code must be added to any page where you want to track conversions. The base code should be placed on every page of your website, whereas the event code only needs to be placed on pages where you want to track conversions. The base code must run before the event code, so place it first.

For example, if you want to track successful checkouts, you should place the base code then the checkout event code between the <head> and </head> tags on your checkout confirmation page. This placement ensures that the codes run as soon as the page is loaded.

On the other hand, 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, you need to make sure that the event code only runs as a result of the action. This requires an understanding of the existing event handlers in your page’s JavaScript code.

Event data

You can provide additional information about an event by attaching an object that contains event data.

Bear in mind that we only offer reporting on value and order_quantity event data at the current time. Any additional event data is available for audience targeting but is not available for conversion reporting.

Value should be sent back along with the appropriate currency code. We will convert the conversion value in Ads Manager reporting to your account currency using the exchange rate between the currency code sent back in the conversion tag and your account's currency.

Event data

Sample value

Type

Audience creation

Conversion reporting

value

100.00

Number (integer or floating point)

order_quantity

1

Integer

currency

USD

One of the following: USD, GBP, CAD, EUR, AUD or NZD

 

product_name

Parker Boots

line_items array

 

product_id

1414

line_items array

 

product_category

Shoes

line_items array

 

product_variant_id

1414-Red

line_items array

 

product_variant

Red

line_items array

 

product_price

99.99

Number (integer or floating point), line_items array

 

product_quantity

1

Integer, line_items array

 

product_brand

Parker

line_items array

 

promo_code

WINTER10

String

 

property

Athleta

String

 

search_query

boots

String

 

video_title

How to style your Parker Boots

String

 

lead_type

Newsletter

String

 

 

The example event code below tracks a checkout event with event data describing a purchase of two products. Bear in mind that this example is the JavaScript portion of the event code. In this example, order_quantity and value are static, but you may want to pass back these values dynamically.

See the value and quantity event data section below for examples of dynamic value and quantity.
 

<script>
 pintrk('track', 'checkout', {
   value: 10.00,
   order_quantity: 2,
   currency: 'USD',
   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
     }
   ]
 });
</script>

Value and quantity event data

Value and order quantity are the two pieces of event data currently available in conversion reporting. If you want to add value and quantity, you can either use static values or pass them back dynamically. If you’d like to pass back value and quantity dynamically as recommended, 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. To track the total value of your sales accurately, we recommend a dynamic variable to track quantity and value in your conversion tags.

Example of hard-coded value and quantity:

<script>
 pintrk('track', 'checkout', {
   value: 10.00, // Read this value (must be a number)
   order_quantity: 5 // Read this quantity (must be an integer)
 });
</script>
<noscript>
 <img height="1" width="1" style="display:none;" alt="" src="https://ct.pinterest.com/v3/?tid=123456789&event=checkout&ed[value]=10.00&ed[order_quantity]=5&noscript=1"/>
</noscript>

Reported value: 10.00

Reported quantity: 5

Example of dynamic value and quantity:

<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 that the setup of dynamic order quantity and value is unique to your website.

Callback

In addition to the event data, you can pass a JavaScript callback function as an optional argument to the function pintrk(). 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.

Example

<script>
 pintrk('track', 'checkout', {
   value: 10.00,
   order_quantity: 2,
   currency: 'USD',
   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>

Next steps

You can view some more examples here. Once you’ve added your base and event codes, you can use the Pinterest Tag helper to confirm that you’ve implemented the tags correctly.

Still need help?
Contact us