Getting Started
Setup Guide
Spotify Server-side GTM (sGTM) Pixel Integration

Spotify Server-side GTM (sGTM) Pixel Integration

Applies to: Brands and Agencies

Google's Server-side tagging (sGTM) (opens in a new tab) is a way to instrument your tags to measure user event activity wherever it happens.

Before you begin

For new clients without a Spotify Pixel:

For existing clients who already have a Spotify Pixel:

  • Navigate to Manage > Your Pixels and click onto your alpha-numeric Pixel ID.  

    • This will enable us to isolate the sGTM traffic and ensure that it is consistent with the previous Javascript setup (if you were previously using Javascript).

    • We encourage you to replace all instances of the JS pixel with the sGTM tracking to ensure consistency.  Failure to do so may lead to a drop in CR.

  • Follow all of the Setup Steps (opens in a new tab) below.

  • After launch and verification, remove the Spotify JS pixel from all pages (if you were previously using Javascript). If the sGTM pixel and the JS pixel both fire, we may count duplicate events which would artificially inflate CR.

Step 1

  1. [REQUIRED] Construct your page view pixel URL:

Parameters:

  • {pixel_id}: Your pixel ID from Manage > Your Pixels (e.g., key=123).
  • {action}: Defines the event type. Use init for page view, lead for leads, or purchase for purchases.
  • {session_id}: A hashed session ID for tracking events by the same visitor.
  • {alias}: Your internal user ID for matching across subdomains.

Example:

https://img.byspotify.com?key={pixel_id}&a={action}&uid={session_id}&alias={alias}

Check out a completed page view example here:

https://img.byspotify.com?key=123&a=init&uid=7375636365737340706f647369676874732e636f6d&alias=abcQ

Populate these values:

FieldDescriptionExample
pixel_idCopy the numeric value found on Manage > Your Pixels.key=123
actionDefines the conversion event type: init (Page view), lead, or purchase.a=init
session_idA hashed session ID, used to distinguish multiple events by the same visitor.uid=7375636365737340706f647369676874732e636f6d
aliasYour internal user ID for matching across subdomains.alias=abc
  1. [Optional] Construct your lead pixel URL:
https://img.byspotify.com?key={pixel_id}&a={action}&uid={session_id}&alias={alias}

Check out a completed lead example here: 

https://img.byspotify.com?key=123&a=lead&uid=7375636365737340706f647369676874732e636f6d&type=newsletter&value=signup  

Populate these values:

FieldDescriptionExample
pixel_idCopy the numeric value found on Manage > Your Pixels.key=123
actionDefines the conversion event type: init (Page view), lead, or purchase.a=init
session_idA hashed session ID, used to distinguish multiple events by the same visitor.uid=7375636365737340706f647369676874732e636f6d
typeLead type.newsletter
valueLead category.signup
  1. [Optional] Construct your purchase pixel URL: 
https://img.byspotify.com?key={pixel_id}&a={action}&uid={session_id}&alias={alias}

Check out a completed purchase example here:

https://img.byspotify.com?key=123&a=purchase&uid=7375636365737340706f647369676874732e636f6d&alias=abc&value=100&currency=USD&order_id=12345  

Populate these values: 

FieldDescriptionExample
pixel_idCopy the numeric value found on Manage > Your Pixels.key=123
actionDefines the conversion event type for purchase.a=purchase
session_idA hashed session ID used to distinguish multiple events by the same visitor.uid=7375636365737340706f647369676874732e636f6d
valueNumerical purchase value.100
currencyThe currency of the purchase.USD
order_idThe order ID for the purchase.12345

Step 2

Pass through these headers:

  • X-Forwarded-For (Required)
  • UserAgent (Required)
  • Referer (Optional - to report on landing page URL)

Step 3

From the Spotify Ad Analytics dashboard, go to Manage > Your Pixels > click onto your alpha-numeric Pixel ID. 

Use the graph to confirm that the raw event daily sum matches expected volume. 

When you hover on the graph, these events will be labeled as Img Init, Img Lead, or Img Purchase to distinguish from JavaScript pixel traffic.

Learn about more Spotify server-side Google Tag Manager Pixel Implementation here (opens in a new tab).