Spotify Pixel Setup, Audio Ad Tracking, and Audience API | OpsBlu Docs

Spotify Pixel Setup, Audio Ad Tracking, and Audience API

Technical guide to Spotify Pixel installation, audio ad conversion tracking, podcast ad measurement, and Spotify Audience Network integration.

How Spotify Ad Tracking Works

Spotify's advertising measurement combines two tracking mechanisms: the Spotify Pixel for web conversion attribution and Spotify's internal streaming signals for in-platform engagement metrics.

The Spotify Pixel is a JavaScript tag placed on advertiser websites that attributes conversions back to Spotify ad exposures (audio, video, or display). The attribution flow works as follows:

  1. Spotify serves an audio, video, or display ad to a user on the Spotify app (mobile, desktop, or web player)
  2. Spotify logs the ad impression with user identifiers tied to the Spotify account
  3. If the user clicks a companion banner or CTA card, they land on the advertiser's website with a sp_click_id parameter
  4. The Spotify Pixel on the advertiser's site reads the click ID and stores it in a first-party cookie
  5. When the user completes a conversion action, the pixel fires an event to Spotify's measurement endpoint
  6. Spotify matches the conversion to the ad exposure using click ID (click-through) or probabilistic matching (view-through)

For audio ads specifically, there is no clickable element during playback. Attribution relies on the companion display banner shown alongside the audio ad, the CTA card displayed after the ad plays, or view-through attribution based on ad exposure followed by a site visit.

Spotify's internal metrics (completion rate, listen-through rate, frequency) are tracked server-side within the Spotify ecosystem and reported in the Ad Studio dashboard.


Installing the Spotify Pixel

Place the Spotify Pixel base code in the <head> of every page on your site. Obtain your pixel ID from Spotify Ad Studio under Measurement > Pixel.

<!-- Spotify Pixel - Base Code -->
<script>
  (function(w, d, t, s, n) {
    w.SpotifyAdsTag = n; w[n] = w[n] || {
      _q: [],
      on: function() { this._q.push(["on"].concat([].slice.call(arguments))) },
      off: function() { this._q.push(["off"].concat([].slice.call(arguments))) },
      emit: function() { this._q.push(["emit"].concat([].slice.call(arguments))) }
    };
    var e = d.createElement(t); e.async = 1; e.src = s;
    var x = d.getElementsByTagName(t)[0]; x.parentNode.insertBefore(e, x);
  })(window, document, 'script', 'https://pixel.byspotify.com/ping.min.js', 'spdt');

  spdt('conf', { key: 'YOUR_PIXEL_ID' });
  spdt('view');
</script>
<noscript>
  <img height="1" width="1" style="display:none"
    src="https://pixel.byspotify.com/pixel?key=YOUR_PIXEL_ID&ev=view" />
</noscript>

Verification

  1. Open DevTools > Network tab and filter for pixel.byspotify.com
  2. Confirm a request fires on page load with the view event
  3. In Spotify Ad Studio, navigate to Measurement > Pixel and check the status indicator
  4. The pixel should show as "Active" within minutes of the first event

Conversion Tracking

Fire conversion events when users complete actions on your site. Spotify supports predefined event types.

Standard Events

<script>
  // Purchase / Transaction
  spdt('purchase', {
    value: 79.99,
    currency: 'USD',
    order_id: 'SP-ORD-12345'
  });

  // Lead form submission
  spdt('lead');

  // Sign up / Registration
  spdt('signup');

  // Add to cart
  spdt('addtocart', {
    value: 39.99,
    currency: 'USD'
  });

  // Start checkout
  spdt('checkout');

  // Page view (already fired by base code, use for specific pages)
  spdt('view');
</script>

Custom Events

<script>
  // Custom event for any action
  spdt('custom', {
    event_name: 'newsletter_subscribe',
    value: 0,
    currency: 'USD'
  });
</script>

Attribution Windows

Configure attribution windows in Spotify Ad Studio when setting up conversion actions:

  • Click-through window: Default 14 days (configurable 1-30 days)
  • View-through window: Default 1 day (configurable 1-7 days)
  • Audio ad exposure counts as a "view" since there is no click during audio playback
  • CTA card clicks and companion banner clicks count as click-through events

Audience and Retargeting

Spotify's Targeting Capabilities

Spotify targeting is configured in Ad Studio during campaign creation. Available targeting dimensions:

  • Demographics: Age (13-65+), gender, location (country, region, DMA, postal code)
  • Listening Behavior: Genre affinity, podcast categories, playlist types
  • Real-Time Context: Platform (mobile, desktop, smart speaker, connected TV), time of day
  • Interest Segments: Predefined segments like "Fitness Enthusiasts," "Gamers," "Commuters" derived from listening patterns
  • Custom Audiences: First-party data uploads and pixel-based retargeting

Pixel-Based Retargeting

Create retargeting audiences from Spotify Pixel data:

  1. In Ad Studio, go to Audiences > Create Audience
  2. Select "Website Activity" as the source
  3. Define rules: all visitors, specific page visitors (URL contains/equals), or event-based (users who fired a specific event)
  4. Set the lookback window (up to 180 days)
  5. Minimum audience size: 1,000 matched users

Custom Audience Upload

Upload first-party data for matching:

  • Email lists: SHA-256 hashed emails, one per row in CSV
  • Device IDs: IDFA (iOS) or AAID (Android) for mobile matching
  • Minimum match size: 1,000 users after matching

Spotify Audience Network

The Spotify Audience Network extends ad delivery beyond the Spotify app to third-party podcasts distributed via Megaphone and other hosting platforms. When enabled, your audio ads can serve across the podcast network with Spotify's targeting applied. This expands reach but reduces control over specific show placement.


Server-Side / API Integration

Spotify Ad Studio does not currently expose a full public API for programmatic campaign management. Campaign creation, targeting, and budget management are handled through the Ad Studio web interface.

However, Spotify provides measurement and reporting endpoints:

Reporting Export

# Spotify Ad Studio provides CSV exports via the dashboard
# For programmatic access, use the Spotify Ads API (limited availability)
# Contact your Spotify account representative for API access

# Example: Fetch campaign performance (requires approved API access)
curl -X GET 'https://ads-api.spotify.com/v1/campaigns/{campaign_id}/stats?start_date=2026-03-01&end_date=2026-03-31' \
  -H 'Authorization: Bearer YOUR_ACCESS_TOKEN'

Server-Side Conversion Tracking

For conversions that cannot be tracked client-side (call center, in-store, CRM events):

# Server-side conversion event
curl -X POST 'https://pixel.byspotify.com/api/v1/conversion' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_PIXEL_API_KEY' \
  -d '{
    "pixel_id": "YOUR_PIXEL_ID",
    "event_name": "purchase",
    "event_time": "2026-03-01T15:30:00Z",
    "user_data": {
      "em": "a1b2c3d4e5f6...",
      "client_ip_address": "203.0.113.1",
      "client_user_agent": "Mozilla/5.0..."
    },
    "custom_data": {
      "value": 149.99,
      "currency": "USD",
      "order_id": "SP-ORD-67890"
    }
  }'

The em field should be a SHA-256 hash of the lowercase, trimmed email address. IP and user agent improve match rates for view-through attribution.


Common Issues

Audio Attribution Gaps

  • Audio ads have no inline click. Attribution depends on companion banner clicks, CTA card clicks, or view-through matching
  • View-through windows are short (default 1 day). Users who hear an ad but visit days later may not be attributed
  • Cross-device attribution is limited. A user hearing an ad on mobile and converting on desktop may not match unless logged into the same browser

Pixel Events Not Appearing in Ad Studio

  • Verify ping.min.js loads from pixel.byspotify.com
  • Check for ad blockers or privacy extensions blocking the pixel domain
  • Ensure the pixel ID matches your Ad Studio account
  • The pixel status may take up to 30 minutes to update in the dashboard

Low Match Rates on Custom Audiences

  • Spotify matches against logged-in user accounts. Users without Spotify accounts will not match
  • Ensure email hashes use SHA-256 on lowercase, whitespace-trimmed addresses
  • Device ID uploads require exact IDFA/AAID format (lowercase with hyphens)
  • The 1,000 minimum match threshold means small lists may not create usable audiences

Podcast Ad Measurement

  • Streaming Ad Insertion (SAI) ads are measured by Spotify for impressions and completions
  • Host-read ads that are baked into the podcast file are harder to measure. Spotify does not track baked-in ad impressions
  • For podcast-specific attribution, use unique landing page URLs or promo codes alongside pixel tracking

Content Security Policy

script-src: pixel.byspotify.com
img-src: pixel.byspotify.com
connect-src: pixel.byspotify.com

Platform-Specific Considerations

Audio Creative Specs: Audio ads must be 15 or 30 seconds, 44.1kHz sample rate, 192kbps+ bitrate, MP3 or OGG format. The companion display banner is 640x640px (JPEG/PNG, max 200KB). CTA cards support a headline (25 chars), body (70 chars), and CTA button text (15 chars).

Free Tier Only: Ads are served only to free-tier Spotify users. Premium subscribers do not hear or see ads. This limits the addressable audience to approximately 350-400M users (out of 600M+ total).

Frequency Capping: Spotify enforces frequency caps to preserve user experience. Default caps vary by format (audio ads typically capped at 2-4 per hour per user). You can set campaign-level frequency caps in Ad Studio.

Brand Lift Studies: Available for campaigns with minimum spend thresholds (typically $25K+). Spotify runs control/exposed surveys to measure awareness, recall, consideration, and favorability lift. Request through your account representative.

Streaming Ad Insertion (SAI): For podcast ads, SAI enables dynamic ad insertion with targeting applied at the time of playback rather than recording. This means the same podcast episode can serve different ads to different listeners. SAI-delivered ads are measured for completion rate and reach within Ad Studio reporting.