How to Add a Spotify Track Preview to Background Music
Want to add a Spotify track to your Background Music widget? While full-length tracks aren’t supported yet, you can easily add a 30-second preview demo.
Follow this short guide to get the Spotify preview link and integrate it into your widget. ⚡️
- 1
-
Go to Spotify and open the track page. The URL should look like this:
https://open.spotify.com/track/4R5hrJSecDyvtD80GZLAGs
- 2
-
Press F12 or Ctrl+Shift+J (Windows/Linux), Cmd+Option+J (Mac) to open the Console:

- 3
-
Copy the following code:
(async () => { const urlMatch = location.href.match(/track\/([a-zA-Z0-9]+)/); if (!urlMatch) return console.error('✖️ Open the track page at open.spotify.com/track/...'); const trackId = urlMatch[1]; const html = await fetch(`https://open.spotify.com/embed/track/${trackId}`).then(r => r.text()); const nextDataMatch = html.match(/<script id="__NEXT_DATA__[^>]*>([^<]+)<\/script>/); if (!nextDataMatch) return console.error('✖️ Track data not found'); const entity = JSON.parse(nextDataMatch[1])?.props?.pageProps?.state?.data?.entity; const previewUrl = entity?.audioPreview?.url; if (previewUrl) { console.log(`%c✔️ "${entity.name}" - ${entity.artists?.[0]?.name}`, 'color: #1DB954; font-weight: bold;'); console.log(`%c${previewUrl}`, 'color: #1DB954; font-size: 14px;'); const el = document.createElement('textarea'); el.value = previewUrl; document.body.appendChild(el); el.select(); document.execCommand('copy'); document.body.removeChild(el); console.log('📋 Copied to clipboard!'); } else { console.warn(`🔇 Preview not available - "${entity?.name}" (not provided by the label)`); } })(); - 4
-
Paste the code into the Console and press Enter:

If your browser blocks pasting, simply type allow pasting in the Console, press Enter, and try again:

- 5
-
Copy the preview link for the Spotify track:

- 6
-
Paste the link into your widget by clicking + Add Track → Add Track by Link:

That's it, you've successfully added the 30-second Spotify track preview to your Background Music widget! 🎶
If you have any questions left, please feel free to contact our Support Team. We will be delighted to assist!




