Zocalo now works with commercetools! Read more about the integration that expands commercetools' capabilities and accelerates deployment on a leading commerce platform. Learn More
Insights / ANALYTICS
TwitterInstagramLinkedInFacebook
INSIGHT

Setting Up Pinterest's CAPI via Google Tag Manager

mcdonough
by John McDonough

Intro

Many online retailers use Pinterest as a key advertising platform due to its active user base that is frequently shopping via the platform. Sending conversion events back to Pinterest when users take key actions on the advertiser website, such as adding to cart or completing a purchase, allows the advertiser to have a better understanding of the value of their ad spend.

Pinterest’s Conversions API (CAPI) enables advertisers to send conversion events to Pinterest via a server-to-server connection. We’ll get into the wider benefits below, but in general, it is recommended that advertisers use Pinterest’s Conversions API to enable more effective tracking. This will provide clearer insights into the impact of your spending, and improve the quality of Pinterest's algorithms.

We’ve worked with many Pinterest advertisers to help them set up their CAPI connections via Google Tag Manager, and have noticed that most find the process intimidating. While we understand why it may look that way from the outside, the truth is that the process is quite straight forward, especially if you already have GA4 tagging in place.

We put the following guide together to demystify the process. This guide assumes that you have already set up the Pinterest tag via GTM, and have GA4 events configured in GTM that correspond to the conversion events you wish to send to Pinterest. Read on to learn how to get Pinterest CAPI set up today.

Table of Contents

Benefits of CAPI

Implementing Pinterest’s CAPI offers all the benefits of any other server-side data collection solution, including:

  • Optimized website performance

    • Moving tracking scripts and activity to the server can reduce the need for JavaScript running on the client side, leading to faster page load times, a more consistent user experience, and less variability across browsers and devices

  • Enhanced tracking accuracy and reliability

    • Server-set first-party cookies are more resilient against browser restrictions and ad blockers, leading to more reliable data collection

  • Ability to send offline sales data

    • If your business has an omni-channel retail experience, sending offline sales data can provide a more complete picture of the impact of advertising

  • Improved data privacy and security

    • Reducing the number of client-side requests limits the exposure of customer data to potential vulnerabilities, while making it easier to anonymize data and comply with privacy guidelines

  • Improved data control, quality, and flexibility

    • Data can be transformed or enriched before being sent to Pinterest

Overview

The image below provides a high-level overview of how your Pinterest and GA4 data collection will work. See the text below for descriptions of each step.

Pinterest - Detailed High-Level Flow
  1. Event Data is sent from the website frontend/Data Layer to the GTM client-side container. This represents the initial tracking data being passed from the website to Google Tag Manager.

  2. The GTM client-side container sends GA4 events to the GTM server container. This allows 1st-party HTTP-only cookies to be set by the server, and moves data processing to the server-side.

  3. The GTM client-side container also sends Pinterest tags with conversion information to Pinterest. This is done for redundancy, in order to improve data coverage and quality.

  4. Within the GTM server container, the tagging server (which can be hosted on cloud providers such as Amazon Web Services (AWS), Azure, or Google Cloud Platform (GCP)) processes the event data received by the GA4 tags. Event data is then formatted into the structure required by each data destination.

  5. Formatted event data is sent from the GTM tagging server to Pinterest (via CAPI) and GA4. This represents the final step where the processed and formatted data is transmitted to the destination platform for analytics or marketing purposes.

Infrastructure Setup

This walkthrough assumes that you already have the infrastructure necessary to run server-side GTM set up. If that’s not the case, please see this guide for how to set up a tagging server on Google Cloud Platform. If you'd prefer to set up your tagging server on AWS or Azure, please contact us for additional guidance.

Client-Side GTM Configuration

This section outlines the steps needed to set up your client-side container with the variables, tags, and settings that will route the necessary data for your Pinterest events to the server container (step 2 in the above diagram).

Variables

Server Container URL

  • Description: This variable is used to capture the tagging server URL you configured during your infrastructure setup. This variable will be referenced in your GA4 Configuration Settings variable in order to direct GA4 hits to your tagging server.

  • Settings:

    • Variable Type: Constant

    • Value: Enter the URL for the custom tagging server you set up as part of the infrastructure configuration.

Server-Side Path Variable

Pinterest Parameters

  • Description: You should set up a variable for any parameters you intend to send to Pinterest, as these will be included in your GA4 Event Settings variable so that they are available to the server.

  • Parameter Details: The below table is a guide to the parameters you may want to include in your GA4 & Pinterest tags, depending on the events you’re sending. We’ve included their status, format, and other requirements for Pinterest’s usage, but we recommend reviewing Pinterest’s documentation as well.

Parameter Name

Pinterest Status

Format

Pinterest Requirements

Implementation Recommendation

Event ID

Required

String

Unique ID string used for deduplication of events

Pass via data layer and set up DL variable. Alternatively, Stape offers a useful variable template.

Email

Required

String

Sha256 hashes of lowercase version of user's email addresses

Pass via data layer and set up DL variable.

Pinterest Click ID

Required

String

1st-Party Cookie Variable. Value: _epik

Phone Number

Recommended

String

Sha256 hashes of user's phone numbers, only digits with country code, area code, and number. Remove any symbols, letters, spaces and leading zeros

Pass via data layer and set up DL variable.

Gender

Recommended

String

Should be hashed value of "f" or "m" or "n", in lowercase

Pass via data layer and set up DL variable.

Date of Birth

Recommended

String

Should be hashed value of birthdate as YYYYMMDD

Pass via data layer and set up DL variable.

Last Name

Recommended

String

Sha256 hashes of lowercase version of user's last name

Pass via data layer and set up DL variable.

First Name

Recommended

String

Sha256 hashes of lowercase version of user's first name

Pass via data layer and set up DL variable.

City

Recommended

String

Sha256 hashes of user's city, in lowercase, and without spaces or punctuation.

Pass via data layer and set up DL variable.

State

Recommended

String

Sha256 hashes of user's state, given as a two-letter code in lowercase

Pass via data layer and set up DL variable.

Zip Code

Recommended

String

Sha256 hashes of user's zipcode, only digits

Pass via data layer and set up DL variable.

Country

Recommended

String

Sha256 hashes of two-character ISO-3166 country code indicating the user's country, in lowercase.

Pass via data layer and set up DL variable.

User ID

Recommended

String

Sha256 hash of internal user ID

Pass via data layer and set up DL variable.

Total Quantity

Recommended

Integer

The gross quantity across all items

Pass via data layer and set up DL variable.

Subtotal

Recommended

Float

Pass via data layer and set up DL variable.

Search Term

Recommended

String

Pass via data layer and set up DL variable.

Notes:

  • Ecommerce details (including item details) will be sent via the Ecommerce object, which is why these parameters are not included in the list above.

Email Client-Side Variable

GA4 Configuration Settings

  • Description: We set up a GA4 configuration settings variable so that we don’t need to set all parameters directly on the tag itself, which can improve extensibility in the future, but ultimately this is a preference. If you do not configure this variable, make sure you include the below settings on your Google Tag directly.

  • Settings:

    • Variable Type: Google Tag Configuration Settings

    • Config Parameters: See table below.

Config Parameter

Value

server_container_url

{{Server Container URL}}

send_page_view

true

Notes:

  • The above example has send_page_view set to true. This may not make sense with how you have your GA4 tags set up; if that’s the case, make sure to set this parameter to false.

GA4 Config Settings Variable

GA4 Event Settings

  • Description: For convenience, we recommend creating a GA4 Event Settings variable that you can apply to all of your GA4 event tags. This will save you from having to set all of your parameters on each tag.

  • Settings:

    • Variable Type: Google Tag: Event Settings

    • Event Parameter: Add each parameter you intend to send to Pinterest, along with the variable that will contain the data. This will look something like this:

Event Parameter

Value

event_id

{{Event ID}}

email

{{dlv - Email}}

epik

{{Pinterest Click ID}}

user_id

{{dlv - User ID}}

subtotal

{{dlv - Subtotal}}

transaction_id

{{dlv - Transaction ID}}

phone_number

{{dlv - Phone Number}}

gender

{{dlv - Gender}}

dob

{{dlv - Date of Birth}}

ln

{{dlv - Last Name}}

fn

{{dlv - First Name}}

ct

{{dlv - City}}

st

{{dlv - State}}

zp

{{dlv - Zip Code}}

country

{{dlv - Country}}

Notes:

  • The above values require you to have set up variables for each parameter as discussed in the Pinterest Parameters section.

  • If you’re not planning on tracking a given parameter, you can leave it out of the table.

  • For most event parameters, the parameter naming convention is up to you. Just keep in mind that you’ll need to adjust the configuration of your variables in the server container if you depart from our recommendations.

GA4 event settings variable

Tags

Pinterest Tags

  • Description: These tags will pass conversion information to Pinterest on the client-side, for redundancy.

  • Settings: The fields to set will depend on the event you’re passing, but we recommend passing at least the following:

    • Tag ID

    • Hashed Email

    • Event to Fire

    • Custom Parameters - Enabled

      • event_id

  • Notes:

    • Make sure you set up the Base Code Only event in addition to whatever conversion events you want to fire. The trigger for this tag should be Initialization - All Pages, to make sure that it fires before any other events have a chance to.

    • If your dev team isn’t able to send an event ID via the data layer, there may be a variable template available in the gallery that can provide this functionality within GTM. Just be careful to validate any gallery templates to ensure they’re trustworthy and reliable.

Pinterest Checkout Tag

Google Tag

  • Description: The Google Tag will be configured to send to the tagging server so that it and all other GA4 events will send their payloads to it, rather than to GA4 directly. This will allow the GTM server-side container to process the data before passing it along to GA4 and Pinterest CAPI.

  • Settings:

    • Tag ID: {{GA4 Measurement ID}}

    • Configuration Settings: {{GA4 Configuration Settings}}

    • Event Settings: {{GA4 Event Settings}}

  • Notes:

    • The configuration settings variable is responsible for setting the destination of GA4 tags. Make sure you’ve followed the guidance for configuring this and related variables above.

GA4 Config Tag

GA4 Events

  • Description: Configure all GA4 event tags as you would otherwise, and the Google Tag will ensure that they are sent to the tagging server.

  • Settings:

    • Tag ID: {{GA4 Measurement ID}}

    • Event Settings: {{GA4 Event Settings}}

  • Note:

    • The event settings variable is responsible for passing the parameters Pinterest is looking for. Make sure you’ve followed the guidance for configuring this and related variables above.

    • If you have any custom parameters you want to send with your GA4 events, either include them in the event settings variable, or add them directly to the tag.

GA4 Purchase Tag

Server-Side GTM Configuration

This section outlines the steps needed to set up your server-side container with the variables, tags, triggers, and transformations, that will send properly formatted data to Pinterest (step 5 in the above diagram).

Variables

Event Data Variables

Description: Because the server-side Pinterest Tag Template has specific ways it looks for certain parameters in the Event Data, you’ll need to create a variable to read many of the parameters you passed in your GA4 Event tags. This list includes:

  • City

  • Country

  • Date of Birth

  • Email

  • External ID (User ID)

  • First Name

  • Gender

  • Last Name

  • Order ID

  • Phone Number

  • Pinterest Click ID

  • Search String

  • State

  • Subtotal

  • Zip Code

Settings: For each of the above parameters you have passed from GA4, use the following configuration:

  • Variable Type: Event Data

  • Key Path: [event parameter key as defined in the GA4 Event Settings variable]

  • Set Default Value: Enabled

  • Default Value: Blank

Notes:

  • Setting the default value to be blank will ensure that the tag does not encounter any issues if a parameter isn’t properly included.

Email Variable

Array Variables

Description: Because the Pinterest CAPI is expecting certain parameters to be passed as arrays, it is necessary to set up a variable for many parameters you intend to include in order to format them as arrays. This applies to the following parameters:

  • City

  • Country

  • Date of Birth

  • Email

  • External ID (User ID)

  • First Name

  • Gender

  • Last Name

  • Phone Number

  • State

  • Zip Code

Settings:

  • Variable Type: Array Builder

  • Value: {{non-array variable name}}

Email Array Variable

Pinterest Event Map

Description: Since Pinterest uses different event names than GA4 in some cases, we use the Pinterest Event Map variable to rename these events before passing them on to Pinterest.

Settings:

  • Variable Type: Lookup Table

  • Input Variable: {{Event Name}}

  • Lookup Table: See table below.

  • Set Default Value: Enabled

  • Default Value: {{Event Name}}

Input

Output

view_item

page_visit

purchase

checkout

view_search_results

search

view_item_list

view_category

video_start

watch_video

generate_lead

lead

sign_up

signup

Notes:

  • We set the default value to use the event name because the add_to_cart event uses the same naming convention in both platforms.

  • If you want to send other events to Pinterest using the custom event, or have other event names that should map to a Pinterest concept, make sure to add these rows to the Lookup Table. For example, we have several clients who use a landing_page_view GA4 event as a trigger for the page_visit Pinterest event.

Pinterest Event Map

Valid Pinterest Events

Description: We use the Valid Pinterest Events variable to assist with our Pinterest Events Trigger, ensuring that the Pinterest tag will only fire for Pinterest events you intend to support.

Settings:

  • Variable Type: Lookup Table

  • Input Variable: {{Event Name}}

  • Lookup Table: See table below.

  • Set Default Value: Enabled

  • Default Value: false

Input

Output

view_item

true

add_to_cart

true

purchase

true

view_search_results

true

view_item_list

true

video_start

true

generate_lead

true

sign_up

true

Notes:

  • If you don’t want to trigger the Pinterest tag on one of the above events, simply remove the row from the lookup table. The default value of falsewill prevent the tag from firing.

  • If there are any additional events that should trigger the Pinterest tag, simply add a row to the lookup table with a value of true.

Valid Pinterest Events

Triggers

Pinterest Events

Description: This trigger is used to ensure the Pinterest tag only fires for supported events.

Settings:

  • Trigger Type: Custom

  • This Trigger fires on Some Events

  • Conditions:

    • Client Name contains GA4

    • Valid Pinterest Events equals true

Pinterest Events

Transformations

Pinterest Parameter Modifications

Description: Because remapping, renaming, and reformatting parameters from the original payload is necessary for proper ingestion by Pinterest (such as building the array variable or event name map), we need to set up a transformation to ensure these values are available to the Pinterest Tag. This transformation adds or overrides parameters in the Event Data Model so that the Pinterest Tag Template can add these fields to the payload sent to Pinterest.

Settings:

  • Transformation Type: Augment Event

  • Parameters to Augument: See table below.

  • Priority: 1000

  • Matching Conditions: Always apply

  • Affected Tags: Some

  • Included Tag Types: Pinterest API for Conversions Tag

Name

Value

event_name

{{Pinterest Event Map}}

order_id

{{Order ID}}

search_string

{{Search String}}

value

{{Subtotal}}

user_data.email_address

{{Email - Pinterest Array}}

user_data.phone_number

{{Phone Number - Pinterest Array}}

user_data.click_id

{{Pinterest Click ID}}

user_data.date_of_birth

{{Date of Birth - Pinterest Array}}

user_data.gender

{{Gender - Pinterest Array}}

user_data.external_id

{{External ID - Pinterest Array}}

user_data.address.first_name

{{First Name - Pinterest Array}}

user_data.address.last_name

{{Last Name - Pinterest Array}}

user_data.address.city

{{City - Pinterest Array}}

user_data.address.region

{{State - Pinterest Array}}

user_data.address.postal_code

{{Zip Code - Pinterest Array}}

user_data.address.country

{{Country - Pinterest Array}}

Notes:

  • If your GA4 implementation is already sending the order subtotal in the valueparameter, adding this parameter and variable is not necessary.

pinterest parameter modifications

GA4 - Remove Pinterest Parameters

Description: If you’re also using your server container to send data to GA4, we recommend configuring this transformation to keep unnecessary parameters from being sent to GA4.

Settings:

  • Transformation Type: Exclude Parameters

  • Parameters to Exclude:

    • event_id

    • email

    • ln

    • fn

    • phone_number

    • ge

    • db

    • ct

    • st

    • zp

    • country

    • epik

  • Matching Conditions: Always apply

  • Affected Tags: Some

  • Included Tag Types: Google Analytics: GA4

remove pinterest parameters

Tags

Pinterest Server-Side

Description: This tag is responsible for building and sending the CAPI payload to Pinterest.

Settings:

  • Tag Type: Pinterest API for Conversions Tag

  • Advertiser ID: {{Pinterest Advertiser ID}}

    • We recommend setting up a constant variable to store your advertiser ID in, but you can also just populate the value directly in this field.

  • API Access Token: {{Pinterest API Access Token}}

    • As with the above, we recommend setting up a constant variable to store your API access token in, but you can also just populate the value directly in this field.

  • Event Name: Inherit from client

  • Test Mode: Disabled

    • When you’re testing your setup, this field should be enabled, so that you can see your events populate inside the Pinterest Business UI in realtime. However, before publishing your setup, make sure to disable this.

  • Trigger: Pinterest Events

Pinterest server side tag

Conclusion

We hope this guide has been helpful. The process for setting up Pinterest’s CAPI is extremely similar to the steps required to set up a CAPI connection for Meta and other advertising platforms. With a few adjustments, you should be able to reuse many of the components covered in this guide to implement these solutions.

If you have any questions, or need assistance setting up CAPI connections, please reach out via the contact link below.

RELATED INSIGHTS
INSIGHT
Using GTM Consent Mode with Hubspot's Cookie Banner
While convenient and useful, Hubspot’s cookie consent banner provides a challenge for sites relying on Google Tag Manager, and their documentation leaves something to be desired for these users. In this article, we’ll walk you through everything you need to know to integrate Hubspot’s cookie consent banner with your GTM setup.
John McDonough
READ MORE  
INSIGHT
The Analytics Missteps Too Many Companies Make
One of the fun (albeit challenging) aspects of analytics consulting is that you get to work with a lot of clients in a number of roles. Because of the nature of the work, you’re typically juggling a few different clients at any given time, and because of the way many clients treat analytics work...
John McDonough
READ MORE  
INSIGHT
Is MACH/headless eCommerce right for you?
To celebrate the launch of Avatria’s new composable commerce accelerator, Zocalo, we wanted to share a few blog posts about some of the thinking that guided our development of the tool.
Anando Naqui
READ MORE  
Have questions or want to chat?