Traditional client-side tags can be blocked by browser extensions or privacy settings. Server-side tagging ensures:
- Improved attribution accuracy
- Reliable conversion tracking
- Enhanced compliance with privacy regulations
Adding Product Catalog Tracking enables Dynamic Retargeting Ads using your product feed.
βοΈ Requirements
Tools & Platforms
- Google Tag Manager Server-Side (sGTM)
- Google Tag Manager Web Container
- Pinterest Business Account
- Product Catalog Feed (XML or CSV)
- Pinterest Tag ID
- Cloud hosting (e.g., Google Cloud Run or App Engine)
π§ Step-by-Step Implementation
1. Set Up Pinterest Conversion API Access
You need your Pinterest Tag ID and an Access Token.
a. Generate Access Token:
- Go to: https://ads.pinterest.com
- Navigate to Business Access > Conversion Access Token
- Generate token for server-side event posting
2. Prepare Your sGTM Environment
a. Create a GTM Server Container:
- Go to tagmanager.google.com
- Click “Admin” > “Create Container” > Choose Server
- Deploy via App Engine (recommended) or Cloud Run
# For App Engine
gcloud app deploy
Once deployed, note your sGTM Endpoint URL (e.g., https://gtm.example.com
)
3. Pinterest Tag Template for sGTM
a. Import a Custom Template (Pinterest Server Tag)
If Pinterest doesnβt provide one officially, create one:
- Go to Templates > New Tag Template
- Use this sample code:
const log = require('logToConsole');
const sendHttpRequest = require('sendHttpRequest');
const JSON = require('JSON');
const eventName = data.event_name;
const userData = data.user_data;
const eventTime = Math.floor(Date.now() / 1000);
const payload = {
event_name: eventName,
event_time: eventTime,
action_source: "website",
user_data: userData,
custom_data: data.custom_data || {}
};
sendHttpRequest(
'https://api.pinterest.com/v5/events',
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${data.access_token}`
}
},
JSON.stringify({
data: [payload]
})
);
log(`Sent Pinterest Event: ${eventName}`);
b. Add Fields:
event_name
user_data
(e.g., email hash, IP, user agent)custom_data
(e.g., product info)access_token
4. Send Events from Web GTM to Server GTM
a. Create Web GTM Tag (Pinterest Event Trigger)
window.dataLayer.push({
event: 'pinterest_server_event',
event_name: 'AddToCart',
user_data: {
em: 'hashed_email_here',
client_ip_address: '{{user_ip}}',
user_agent: navigator.userAgent
},
custom_data: {
currency: 'USD',
value: 59.99,
content_ids: ['SKU123'],
content_type: 'product'
}
});
5. Create Tag in Server GTM for Pinterest
a. Variables
Extract event_name
, user_data
, and custom_data
from event object
b. Trigger
- Custom Event Trigger:
pinterest_server_event
c. Tag
- Use your custom Pinterest CAPI tag
- Pass the required fields:
event_name
user_data
custom_data
access_token
(stored as Constant variable)
ποΈ Product Catalog Setup
6. Prepare and Upload Product Feed
a. Create Catalog Feed File
CSV Format Example:
id,title,description,link,image_link,price,availability
1234,Blue T-Shirt,"Cotton, size M",https://store.com/p/1234,https://store.com/i/1234.jpg,29.99 USD,in stock
XML Format Example:
<rss version="2.0" xmlns:g="http://base.google.com/ns/1.0">
<channel>
<title>Product Feed</title>
<item>
<g:id>1234</g:id>
<g:title>Blue T-Shirt</g:title>
<g:description>Cotton, size M</g:description>
<g:link>https://store.com/p/1234</g:link>
<g:image_link>https://store.com/i/1234.jpg</g:image_link>
<g:price>29.99 USD</g:price>
<g:availability>in stock</g:availability>
</item>
</channel>
</rss>
b. Upload to Pinterest
- Go to Catalog Manager
- Add new data source URL or schedule via FTP/HTTPS
7. Enable Dynamic Retargeting
Pinterest matches content_ids
from your server events with the catalog feed.
Ensure:
- The
content_ids
incustom_data
match theid
field in feed - Events like
PageVisit
,ViewCategory
,AddToCart
, andPurchase
are firing
Example:
{
"event_name": "Purchase",
"custom_data": {
"content_ids": ["1234"],
"currency": "USD",
"value": 99.00,
"order_id": "ORDER789"
}
}
β Final Testing & Validation
Use Pinterest Tag Helper Chrome Extension
- Validate real-time event tracking
- Confirm server-side events match product catalog
Use Pinterest CAPI Event Logging Tool (Beta)
- Request from your Pinterest rep
π Best Practices
- Hash PII (SHA-256) before sending
email
orphone
- Set up failover logging for failed Pinterest requests in sGTM
- Include Consent Mode logic if in EU
- Regularly sync product catalog to keep IDs updated
- Use Debug Mode in GTM for end-to-end testing
π Bonus: Add Pinterest Purchase Deduplication
To avoid duplicate tracking:
- Send client-side
event_id
along with server-side - Include
event_id
field in both
{
"event_name": "Purchase",
"event_id": "xyz123",
...
}
Pinterest will deduplicate based on event_id
.
π Summary
Setting up server-side Pinterest tag with product catalog tracking provides robust, privacy-compliant conversion tracking and retargeting capabilities. Youβll gain better accuracy, reduce reliance on browser-based tracking, and unlock dynamic ad features using your catalog.