Lägg till dina händelsekoder

Du verkar titta på det här från en region där Pinterest-taggen inte är tillgänglig ännu. Se var taggen finns tillgänglig för Pinterest Business-konton.

Mer information

Med händelsekoder kan du mäta den påverkan dina Pinterest-annonser har på vissa åtgärder på webbplatsen. De är också nödvändiga för att starta kampanjer som automatiskt kommer att optimeras mot specifika händelser. 

Innan du börjar: Du måste ha baskoden installerad innan du kan lägga till dina händelsekoder. Se till att dina händelsekoder körs efter din baskod.

Kopiera händelsekod i Annonshanteraren

  1. Öppna Annonshanteraren.
  2. Från rullgardinsmenyn Annonser väljer du Konversioner.
  3. Välj din tagg.
  4. Kopiera koden för händelsen du vill spåra.
     

Lägg till händelsekoden på din webbplats

För att spåra händelser måste du lägga till ett HTML-kodavsnitt i webbplatsens kod.

  1. Öppna koden för sidan där du vill spåra en händelse.
  2. Klistra in händelsekoden:
    • Händelser som laddas på sidan körs när sidan laddas: Klistra in i rubriken innan baskoden.
    • Händelser som laddas av användare körs när de utlöses av en åtgärd: Exakta steg för implementering är beroende av ditt användningsfall och de händelser du spårar.

Det finns händelser som du kan spåra med Pinterest-taggen och om de innehåller målgruppsskapande och konversionsrapportering. 

Händelse

Målgruppsskapande

Konversionsrapport

Köp

Lagd i varukorg

Sidbesök

Registrering

Videovisning

Kundämne

Sökning

Visa kategori

Anpassad*

[Användardefinierad händelse]**

 

*Spåra en anpassad händelse. Använd det här händelsenamnet för att spåra en speciell händelse som du vill inkludera i din konversionsrapport
**Lägg till eventuella ytterligare händelser som du har definierat för målgruppen. Unika händelser är inte tillgängliga för konversionsrapportering. Kom ihåg att mellanslag kommer att beskäras från de ursprungliga händelsenamnen som körs genom taggen

 

Vad är nästa steg?

Kontrollera för att se att allt fungerar korrekt:  Såhär verifierar du Pinterest-taggen

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.

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 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 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

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.

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

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 confirm 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.

Behöver du fortfarande hjälp?
Kontakta oss