新增事件代碼

您似乎在未提供 Pinterest 標籤的地區瀏覽此內容。 請查看可供 Pinterest Business 帳號使用 Pinterest 標籤的地區。

瞭解詳情

事件代碼可讓你衡量 Pinterest 廣告對特定網站行動的影響。要啟動對特定事件自動優化的宣傳活動也需要用到事件代碼。 

開始之前:必須先安裝基本代碼,然後才能加入事件代碼。請確認事件代碼在基本代碼後執行。

在廣告管理員中複製事件代碼

  1. 開啟廣告管理員。
  2. 「廣告」下拉選單中選擇「轉換率」。
  3. 選擇您的標籤。
  4. 複製想追蹤事件的代碼。
     

新增事件代碼到您的網站

若要追蹤事件,需要將 HTML 的代碼片段加到您的網站代碼。

  1. 開啟想要追蹤事件的所處網頁代碼。
  2. 複製事件代碼:
    • 網頁載入事件在載入頁面時觸發:貼在標頭中基本代碼之前。
    • 使用者行動事件由引起行動時觸發:具體實施步驟取決於您的用例及您追蹤的事件。

以下是您可使用 Pinterest 標籤追蹤的事件,以及標籤是否包含目標對象建立和轉換率報告。  

事件

目標對象建立

轉換率報告

Checkout

AddToCart

PageVisit

Signup

WatchVideo

Lead

Search

ViewCategory

自訂*

[使用者定義的事件]**

 

*追蹤自訂事件。使用此事件名稱追蹤您想要包括在轉換率報告中的特殊事件
**新增任何您已為鎖定目標對象用途而定義的其他事件。轉換率報告無法使用不重複事件。請注意,原始事件名稱中的空白字元在透過標籤傳遞時會遭到刪除

 

下一步是什麼?

檢查一切是否正常運作:如何驗證 Pinterest 標籤 

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

仍需要協助?
請與我們聯繫