<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Spotify iFrame tracking via GTM. Any code? in Spotify for Developers</title>
    <link>https://community.spotify.com/t5/Spotify-for-Developers/Spotify-iFrame-tracking-via-GTM-Any-code/m-p/5570757#M9001</link>
    <description>&lt;P&gt;Hello Team,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was trying to track Spotify embed on my website via gtm, I tried searching a lot on Google but didn't find any solution. Can you help me with a code to track Spotify's iframe on a website with GTM?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Tanuj&lt;/P&gt;</description>
    <pubDate>Thu, 27 Apr 2023 10:27:28 GMT</pubDate>
    <dc:creator>wop9825</dc:creator>
    <dc:date>2023-04-27T10:27:28Z</dc:date>
    <item>
      <title>Spotify iFrame tracking via GTM. Any code?</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Spotify-iFrame-tracking-via-GTM-Any-code/m-p/5570757#M9001</link>
      <description>&lt;P&gt;Hello Team,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was trying to track Spotify embed on my website via gtm, I tried searching a lot on Google but didn't find any solution. Can you help me with a code to track Spotify's iframe on a website with GTM?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Tanuj&lt;/P&gt;</description>
      <pubDate>Thu, 27 Apr 2023 10:27:28 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Spotify-iFrame-tracking-via-GTM-Any-code/m-p/5570757#M9001</guid>
      <dc:creator>wop9825</dc:creator>
      <dc:date>2023-04-27T10:27:28Z</dc:date>
    </item>
    <item>
      <title>Re: Spotify iFrame tracking via GTM. Any code?</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Spotify-iFrame-tracking-via-GTM-Any-code/m-p/5572521#M9026</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Howldy wop9825,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Sure! Here is a step-by-step guide to track Spotify embed on your website via GTM:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;First, you need to create a new Tag in your Google Tag Manager account. Go to Tags &amp;gt; New &amp;gt; Tag, and select "Custom HTML" as the Tag type.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Copy and paste the following code snippet into the HTML field:&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;script&amp;gt;
// Listen for the Spotify player to load
window.addEventListener('message', function(event) {
  if (event.origin === 'https://open.spotify.com') {
    // Spotify player is ready, send an event to Google Tag Manager
    dataLayer.push({
      event: 'spotifyReady',
      spotifyUri: event.data.uri
    });
  }
}, false);
&amp;lt;/script&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;Save the Tag and give it a descriptive name like "Spotify Embed Tracker".&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Next, you need to create a new Trigger that fires when the Spotify player is ready. Go to Triggers &amp;gt; New &amp;gt; Trigger, and select "Custom Event" as the Trigger type.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;In the "Event name" field, enter "spotifyReady".&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Save the Trigger and give it a descriptive name like "Spotify Embed Ready".&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Finally, you need to associate the new Tag and Trigger with your Spotify embed. To do this, go to your website and find the code for your Spotify embed.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Add the following code snippet to your Spotify embed code, replacing "YOUR-GTM-CONTAINER-ID" with the ID of your Google Tag Manager container:&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;iframe src="https://open.spotify.com/embed/track/3qN5qMTKyEEmiTZD38CmPA" width="300" height="380" frameborder="0" allowtransparency="true" allow="encrypted-media"&amp;gt;&amp;lt;/iframe&amp;gt;
&amp;lt;script&amp;gt;
// Send a message to the Spotify player to let it know our domain
var spotifyPlayer = document.querySelector('iframe[src^="https://open.spotify.com"]');
spotifyPlayer.contentWindow.postMessage({
  type: 'listeningOn',
  domain: window.location.hostname,
  gtmId: 'YOUR-GTM-CONTAINER-ID'
}, 'https://open.spotify.com');
&amp;lt;/script&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN&gt;Save the changes to your Spotify embed code and publish your website.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Now, whenever a user loads your website and interacts with the Spotify embed, an event will be sent to your Google Tag Manager account with the Spotify URI of the track that was played. You can use this information to create custom reports and track user behavior on your website.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I'll be barking up the wrong tree without updates on your situation!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;-Prague the Dog&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 30 Apr 2023 04:19:11 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Spotify-iFrame-tracking-via-GTM-Any-code/m-p/5572521#M9026</guid>
      <dc:creator>Prague</dc:creator>
      <dc:date>2023-04-30T04:19:11Z</dc:date>
    </item>
    <item>
      <title>Re: Spotify iFrame tracking via GTM. Any code?</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Spotify-iFrame-tracking-via-GTM-Any-code/m-p/5623082#M10327</link>
      <description>&lt;P&gt;Hi Prague the Dog,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks for sharing. Unfortunately, it seems not to work for me. I try to track play on a podcast show, but there are no events coming up, when clicking the play button. Any ideas how to fix?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;</description>
      <pubDate>Tue, 15 Aug 2023 12:28:32 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Spotify-iFrame-tracking-via-GTM-Any-code/m-p/5623082#M10327</guid>
      <dc:creator>dasgelbevomei</dc:creator>
      <dc:date>2023-08-15T12:28:32Z</dc:date>
    </item>
    <item>
      <title>Re: Spotify iFrame tracking via GTM. Any code?</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Spotify-iFrame-tracking-via-GTM-Any-code/m-p/5623136#M10328</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;shouldn't the listener tag be triggered by "All Pages" instead of only when the "spotifyReady" event comes up? Otherwise, the "spotifyReady" event would never come up, or I'm mistaken?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I integrate the tag on "All pages" and click on the play button, the event "spotifyReady" comes up every second.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Perhaps you described this step incorrectly in your tutorial?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyway, thank you very much for your effort!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Aug 2023 13:41:17 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Spotify-iFrame-tracking-via-GTM-Any-code/m-p/5623136#M10328</guid>
      <dc:creator>dasgelbevomei</dc:creator>
      <dc:date>2023-08-15T13:41:17Z</dc:date>
    </item>
    <item>
      <title>Re: Spotify iFrame tracking via GTM. Any code?</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Spotify-iFrame-tracking-via-GTM-Any-code/m-p/5656031#M11200</link>
      <description>&lt;P&gt;Did this ever start working for you?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Are you able to track events properly?&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2023 00:21:27 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Spotify-iFrame-tracking-via-GTM-Any-code/m-p/5656031#M11200</guid>
      <dc:creator>KloutedKnight</dc:creator>
      <dc:date>2023-10-23T00:21:27Z</dc:date>
    </item>
    <item>
      <title>Re: Spotify iFrame tracking via GTM. Any code?</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Spotify-iFrame-tracking-via-GTM-Any-code/m-p/5656102#M11203</link>
      <description>&lt;P&gt;No, not really as discribed in the tutorial. But with the tag been triggered by "All Pages“ it seems to work for what I want to archive. When I strictly stick with the tutorial an event would never come up for me.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2023 08:09:23 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Spotify-iFrame-tracking-via-GTM-Any-code/m-p/5656102#M11203</guid>
      <dc:creator>dasgelbevomei</dc:creator>
      <dc:date>2023-10-23T08:09:23Z</dc:date>
    </item>
    <item>
      <title>Re: Spotify iFrame tracking via GTM. Any code?</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Spotify-iFrame-tracking-via-GTM-Any-code/m-p/5780261#M12008</link>
      <description>&lt;P&gt;This worked for me when I changed the trigger type, but I had to change the tag trigger to fire on "All Initialization Events" to get it to work.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Dec 2023 16:20:32 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Spotify-iFrame-tracking-via-GTM-Any-code/m-p/5780261#M12008</guid>
      <dc:creator>LeonBarton</dc:creator>
      <dc:date>2023-12-28T16:20:32Z</dc:date>
    </item>
    <item>
      <title>Re: Spotify iFrame tracking via GTM. Any code?</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Spotify-iFrame-tracking-via-GTM-Any-code/m-p/6438613#M15244</link>
      <description>&lt;P&gt;I have the same problem that you? How did you fix it? Because if&amp;nbsp;&lt;SPAN&gt;chenge the triggered by "All Pages“ i still with the same problem,&amp;nbsp;the event "spotifyReady" comes up every second&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Oct 2024 08:32:17 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Spotify-iFrame-tracking-via-GTM-Any-code/m-p/6438613#M15244</guid>
      <dc:creator>JoannaReyes</dc:creator>
      <dc:date>2024-10-15T08:32:17Z</dc:date>
    </item>
    <item>
      <title>Re: Spotify iFrame tracking via GTM. Any code?</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Spotify-iFrame-tracking-via-GTM-Any-code/m-p/6945919#M17761</link>
      <description>&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;Version 0.0.1:&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So what I'm doing right now is&lt;/P&gt;&lt;P&gt;1. I printed &lt;STRONG&gt;'event'&lt;/STRONG&gt; to the console to see its parameters and found out the URI is not at &lt;EM&gt;'event.data.uri'&lt;/EM&gt; but at &lt;STRONG&gt;'event.data.payload.playingURI'&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;2. I created a JS variable name &lt;STRONG&gt;'spotifyLastURI'&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;2.1. This variable is then used to detect whether the URI has changed or was empty, so the dataLayer event will &lt;STRONG&gt;trigger only when the URI is different&lt;/STRONG&gt;, because (as folks commented above) it kept triggering non-stop, and the problem was that it also wasn't bringing the valuable information (spotify's URI) for me.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;script&amp;gt;
spotifyLastURI = '';
window.addEventListener('message', function(event) {
  if (event.origin === 'https://open.spotify.com') {
    if (event.data.payload.playingURI &amp;amp;&amp;amp; spotifyLastURI != event.data.payload.playingURI) {
      dataLayer.push({
        event: 'spotifyReady',
        spotifyUri: event.data.payload.playingURI
      });
      spotifyLastURI = event.data.payload.playingURI;
    }
  } 
}, false);
&amp;lt;/script&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 May 2025 18:52:34 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Spotify-iFrame-tracking-via-GTM-Any-code/m-p/6945919#M17761</guid>
      <dc:creator>tomasfn87</dc:creator>
      <dc:date>2025-05-08T18:52:34Z</dc:date>
    </item>
    <item>
      <title>Re: Spotify iFrame tracking via GTM. Any code?</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Spotify-iFrame-tracking-via-GTM-Any-code/m-p/6945928#M17762</link>
      <description>&lt;P&gt;And now my &lt;STRONG&gt;'spotifyReady'&lt;/STRONG&gt; event actually brings something useful:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
  event: "spotifyReady",
  gtm.uniqueEventId: 45,
  spotifyUri: "spotify:album:2hLNxoJZ5kZoBEX0XGBRNu"
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 04 May 2025 11:04:35 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Spotify-iFrame-tracking-via-GTM-Any-code/m-p/6945928#M17762</guid>
      <dc:creator>tomasfn87</dc:creator>
      <dc:date>2025-05-04T11:04:35Z</dc:date>
    </item>
    <item>
      <title>Re: Spotify iFrame tracking via GTM. Any code?</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Spotify-iFrame-tracking-via-GTM-Any-code/m-p/6945950#M17763</link>
      <description>&lt;P&gt;The next step was to add a new DLV (dataLayer variable) in Google Tag Manager named &lt;STRONG&gt;'spotifyUri'&lt;/STRONG&gt; and used it as a parameter in a GA4 tag.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I'm now able to register which Spotify's content was loaded dinamically in my website, which is a good working point.&amp;nbsp;I'd love to actually register which &lt;STRONG&gt;Artist&lt;/STRONG&gt;, &lt;STRONG&gt;Song&lt;/STRONG&gt;, &lt;STRONG&gt;Album&lt;/STRONG&gt;, &lt;STRONG&gt;Playlist&lt;/STRONG&gt; or &lt;STRONG&gt;Episode&lt;/STRONG&gt; was loaded since it's possible that content may be removed in the future and I'll never know what it actually was because I won't be able to visit the link. But it solves most people's problems, I guess!&lt;/P&gt;</description>
      <pubDate>Sun, 04 May 2025 11:09:28 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Spotify-iFrame-tracking-via-GTM-Any-code/m-p/6945950#M17763</guid>
      <dc:creator>tomasfn87</dc:creator>
      <dc:date>2025-05-04T11:09:28Z</dc:date>
    </item>
    <item>
      <title>Re: Spotify iFrame tracking via GTM. Any code?</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Spotify-iFrame-tracking-via-GTM-Any-code/m-p/6946639#M17769</link>
      <description>&lt;P&gt;It works very nice. And you can monitor via GA4's Realtime report.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;Events' card (GA4 Realtime):&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="spotify-ga4-01.png" style="width: 999px;"&gt;&lt;img src="https://community.spotify.com/t5/image/serverpage/image-id/194944i40E4DADFB2A0F33A/image-size/large?v=v2&amp;amp;px=999" role="button" title="spotify-ga4-01.png" alt="spotify-ga4-01.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;GTM - GA4 tag for Spotify Content:&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="spotify-ga4-02.png" style="width: 999px;"&gt;&lt;img src="https://community.spotify.com/t5/image/serverpage/image-id/194945i0964F8C8FD09859C/image-size/large?v=v2&amp;amp;px=999" role="button" title="spotify-ga4-02.png" alt="spotify-ga4-02.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 May 2025 14:17:18 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Spotify-iFrame-tracking-via-GTM-Any-code/m-p/6946639#M17769</guid>
      <dc:creator>tomasfn87</dc:creator>
      <dc:date>2025-05-08T14:17:18Z</dc:date>
    </item>
    <item>
      <title>Re: Spotify iFrame tracking via GTM. Any code?</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Spotify-iFrame-tracking-via-GTM-Any-code/m-p/6946652#M17770</link>
      <description>&lt;P&gt;I updated some outdated references and added a variable to allow the dataLayer event to be triggered only once for each new content loaded into the player.&lt;/P&gt;</description>
      <pubDate>Sun, 04 May 2025 11:16:42 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Spotify-iFrame-tracking-via-GTM-Any-code/m-p/6946652#M17770</guid>
      <dc:creator>tomasfn87</dc:creator>
      <dc:date>2025-05-04T11:16:42Z</dc:date>
    </item>
    <item>
      <title>Re: Spotify iFrame tracking via GTM. Any code?</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Spotify-iFrame-tracking-via-GTM-Any-code/m-p/6949504#M17780</link>
      <description>&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;Version 0.0.2:&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;For a more robust implementation and to be able to detect multiple events as the content is played:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;- &lt;EM&gt;audio_playback_started&lt;/EM&gt;;&lt;/P&gt;&lt;P&gt;- &lt;EM&gt;audio_playback_paused&lt;/EM&gt;;&lt;/P&gt;&lt;P&gt;- &lt;EM&gt;audio_playback_resumed&lt;/EM&gt;;&lt;/P&gt;&lt;P&gt;- &lt;EM&gt;audio_complete;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;- &lt;EM&gt;audio_progress&lt;/EM&gt; (with configurable detection values' array i.e. [25, 50, 75]);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Parameters:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;- &lt;EM&gt;audio_content&lt;/EM&gt;;&lt;/P&gt;&lt;P&gt;-&amp;nbsp;&lt;EM&gt;audio_content_type&lt;/EM&gt;;&lt;/P&gt;&lt;P&gt;- &lt;EM&gt;audio_current_time&lt;/EM&gt;;&lt;/P&gt;&lt;P&gt;- &lt;EM&gt;audio_duration;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;- &lt;EM&gt;audio_percent&lt;/EM&gt;;&lt;/P&gt;&lt;P&gt;- &lt;EM&gt;audio_provider&lt;/EM&gt;;&lt;/P&gt;&lt;P&gt;- &lt;EM&gt;audio_status&lt;/EM&gt;;&lt;/P&gt;&lt;P&gt;-&lt;EM&gt;&amp;nbsp;audio_url.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;GTM Custom HTML Spotify Audio Tag:&lt;/STRONG&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;script&amp;gt;
(function spotifyAudioListenerTag() {
  // - Edit the list below to setup Progress events detected
  // percentage values:
  var spotifyPercentagesToBeDetected = [
    10, 20, 30, 40, 50, 60, 70, 80, 90, 99
  ]
  // - The operation below is needed to ensure the list of
  // percentages to be detected as progress events follow
  // the correct format.
  spotifyPercentagesToBeDetected = (function(arr) {
    var onlyNumsTruncatedList = arr.filter(function(element) {
      return typeof element === 'number';
    }).map(function(element) {
      return Math.trunc(element);
    }).filter(function(element) {
      return element &amp;gt; 0 &amp;amp;&amp;amp; element &amp;lt; 100;
    });
    var uniqueValuesObject = {};
    for (var i = 0; i &amp;lt; onlyNumsTruncatedList.length; i++) {
      uniqueValuesObject[onlyNumsTruncatedList[i]] = true;
    }
    var uniqueList = Object.keys(uniqueValuesObject).map(function(key) {
      return parseInt(key, 10);
    });
    uniqueList.sort(function(a, b) {
      return a - b;
    });
    return uniqueList;
  })(spotifyPercentagesToBeDetected);
  var minDetectionValue = Math.min.apply(null, spotifyPercentagesToBeDetected);

  // - Check if a calculated percentage value should or
  // not be detected.
  function shouldPercentageBeDetected(percent, detectionList) {
    for (var i = 0; i &amp;lt; detectionList.length; i++) {
      if (percent &amp;gt;= detectionList[i] &amp;amp;&amp;amp; !(detectionList[i+1] &amp;amp;&amp;amp; detectionList[i+1] &amp;lt;= percent)) {
        return { check: true, value: detectionList[i] };
      }
    }
    return { check: false, value: undefined };
  }

  window.dataLayer = window.dataLayer || [];
  var spotifyWasPaused = false;
  var spotifyRegisteredProgress = [];
  var spotifyLastDuration = 0.0;
  var spotifyLastURI = '';
  var spotifyLastEventString = '';
  sessionStorage.setItem('spotifyLastStatus', '');
  window.addEventListener('message', function(event) {
    // Leave if not a Spotify Event
    if (!(event.origin === 'https://open.spotify.com'))
      return;
    var spotifyEventString = event.data.payload
      &amp;amp;&amp;amp; (JSON.stringify(event.data.payload.isPaused)
      + JSON.stringify(event.data.payload.position)
      + JSON.stringify(event.data.payload.playingUri)) || '';
    // Leave if the current event is the same as last event or if the player is buffering
    if (spotifyEventString === spotifyLastEventString || event.data.payload.isBuffering)
      return;
    else
      spotifyLastEventString = spotifyEventString;
    var audioPercent = Math.trunc((event.data.payload.position / event.data.payload.duration) * 100) || 0;
    var audioCurrentTime = (event.data.payload.position / 1000) || 0;
    var audioDuration = (event.data.payload.duration / 1000) || 0;
    var spotifyURI = event.data.payload.playingURI;
    var reSpotifyUri = /spotify:([^:]+):([^:]+)/i;
    var audioData = (function(uri) {
      var result = { contentType: '', url: '' };
      if (reSpotifyUri.test(uri)) {
        var parts = reSpotifyUri.exec(uri);
        result.contentType = parts &amp;amp;&amp;amp; parts[1];
        result.url = parts &amp;amp;&amp;amp; 'https://open.spotify.com/'+parts[1]+'/'+parts[2];
      }
      return result;
    })(spotifyURI);
    var spotifyEvent = {
      event: 'spotifyEvent',
      audioPercent: audioPercent,
      audioCurrentTime: audioCurrentTime,
      audioDuration: audioDuration,
      audioContentType: audioData.contentType,
      audioUrl: audioData.url,
      spotifyURI: spotifyURI
    }
    // - Detect playback restart
    if ((sessionStorage.getItem('spotifyLastStatus') === 'complete'
      &amp;amp;&amp;amp; audioData.contentType !== 'episode') || event.data.type === 'playback_started')
      sessionStorage.setItem('spotifyLastStatus', 'playback_started');
    // - Detect track rewind or restart
    if (audioData.contentType === 'track' &amp;amp;&amp;amp; audioPercent &amp;lt; minDetectionValue) {
      spotifyWasPaused = false;
      spotifyRegisteredProgress = [];
    }
    // - Restart Playback Control Variables in case URI or duration has
    // changed or a complete event has just fired (track change detection
    // within playlist, album or artist).
    if ((spotifyURI &amp;amp;&amp;amp; spotifyURI !== spotifyLastURI)
      || event.data.type === 'playback_started'
      || sessionStorage.getItem('spotifyLastStatus') === 'complete'
      || (spotifyURI &amp;amp;&amp;amp; spotifyURI === spotifyLastURI
        &amp;amp;&amp;amp; Math.trunc(audioDuration) !== Math.trunc(spotifyLastDuration))) {
      spotifyWasPaused = false;
      spotifyRegisteredProgress = [];
    }
    // 1. Playback updates
    // 1.1. Playback Start
    if (spotifyURI &amp;amp;&amp;amp; event.data.type === 'playback_started') {
      spotifyEvent.audioStatus = 'playback_started';
      window.dataLayer.push(spotifyEvent);
      spotifyLastURI = spotifyURI;
      spotifyLastStatus = spotifyEvent.audioStatus;
      // 1.2. Playback Paused
    } else if (spotifyURI &amp;amp;&amp;amp; event.data.type === 'playback_update' &amp;amp;&amp;amp; event.data.payload.isPaused
      &amp;amp;&amp;amp; audioCurrentTime &amp;amp;&amp;amp; !spotifyWasPaused) {
      spotifyEvent.audioStatus = 'playback_paused';
      window.dataLayer.push(spotifyEvent);
      spotifyLastURI = spotifyURI;
      spotifyLastDuration = audioDuration;
      spotifyWasPaused = true;
      sessionStorage.setItem('spotifyLastStatus', spotifyEvent.audioStatus);
      // 1.3. Playback Resumed
    } else if (spotifyURI &amp;amp;&amp;amp; event.data.type === 'playback_update'
      &amp;amp;&amp;amp; !event.data.payload.isPaused &amp;amp;&amp;amp; spotifyWasPaused &amp;amp;&amp;amp; event.data.payload.position) {
      spotifyEvent.audioStatus = 'playback_resumed';
      window.dataLayer.push(spotifyEvent);
      spotifyLastURI = spotifyURI;
      spotifyLastDuration = audioDuration;
      spotifyWasPaused = false;
      sessionStorage.setItem('spotifyLastStatus', spotifyEvent.audioStatus);
      // 1.4. Complete
    } else if (spotifyURI &amp;amp;&amp;amp; event.data.type === 'playback_update' &amp;amp;&amp;amp; audioDuration === audioCurrentTime
      &amp;amp;&amp;amp; sessionStorage.getItem('spotifyLastStatus') !== 'complete') {
      spotifyEvent.audioStatus = 'complete';
      spotifyEvent.audioPercent = 100;
      window.dataLayer.push(spotifyEvent);
      spotifyLastURI = spotifyURI;
      spotifyLastDuration = audioDuration;
      sessionStorage.setItem('spotifyLastStatus', spotifyEvent.audioStatus);
    }
    // - No progress events after a complete event
    if (sessionStorage.getItem('spotifyLastStatus') === 'complete')
      return;
    // 2. Progress Events
    if (spotifyURI &amp;amp;&amp;amp; shouldPercentageBeDetected(audioPercent, spotifyPercentagesToBeDetected).check) {
      if (!spotifyRegisteredProgress.includes(shouldPercentageBeDetected(audioPercent, spotifyPercentagesToBeDetected).value)) {
        spotifyRegisteredProgress.push(shouldPercentageBeDetected(audioPercent, spotifyPercentagesToBeDetected).value);
        spotifyEvent.audioStatus = 'progress';
        spotifyEvent.audioPercent = shouldPercentageBeDetected(audioPercent, spotifyPercentagesToBeDetected).value;
        window.dataLayer.push(spotifyEvent);
        spotifyLastURI = spotifyURI;
        spotifyLastDuration = audioDuration;
      }
    }
  }, false);
})();
&amp;lt;/script&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;GTM GA4 Tag:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="tomasfn87_1-1747188200616.png" style="width: 999px;"&gt;&lt;img src="https://community.spotify.com/t5/image/serverpage/image-id/195348i5234D296BEF69E24/image-size/large?v=v2&amp;amp;px=999" role="button" title="tomasfn87_1-1747188200616.png" alt="tomasfn87_1-1747188200616.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;GTM GA4 Spotify Event Trigger:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="tomasfn87_2-1746702012964.png" style="width: 999px;"&gt;&lt;img src="https://community.spotify.com/t5/image/serverpage/image-id/195137iACEAB2632CCA781B/image-size/large?v=v2&amp;amp;px=999" role="button" title="tomasfn87_2-1746702012964.png" alt="tomasfn87_2-1746702012964.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;GTM Folder:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="tomasfn87_2-1747188253461.png" style="width: 999px;"&gt;&lt;img src="https://community.spotify.com/t5/image/serverpage/image-id/195349i0D812A48F0A8940D/image-size/large?v=v2&amp;amp;px=999" role="button" title="tomasfn87_2-1747188253461.png" alt="tomasfn87_2-1747188253461.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;DataLayer events for a Spotify Episode: &lt;EM&gt;playback_started &lt;/EM&gt;&lt;/STRONG&gt;(6)&lt;STRONG&gt;, &lt;EM&gt;progress&amp;nbsp;&lt;/EM&gt;&lt;/STRONG&gt;(from 7 to 16; from 18 to 25)&lt;STRONG&gt; and &lt;EM&gt;complete&amp;nbsp;&lt;/EM&gt;&lt;/STRONG&gt;(17)&lt;STRONG&gt; events:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="tomasfn87_0-1747197568384.png" style="width: 999px;"&gt;&lt;img src="https://community.spotify.com/t5/image/serverpage/image-id/195353i7707187AE5B00DA9/image-size/large?v=v2&amp;amp;px=999" role="button" title="tomasfn87_0-1747197568384.png" alt="tomasfn87_0-1747197568384.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 25 Oct 2025 13:17:08 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Spotify-iFrame-tracking-via-GTM-Any-code/m-p/6949504#M17780</guid>
      <dc:creator>tomasfn87</dc:creator>
      <dc:date>2025-10-25T13:17:08Z</dc:date>
    </item>
    <item>
      <title>Re: Spotify iFrame tracking via GTM. Any code?</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Spotify-iFrame-tracking-via-GTM-Any-code/m-p/6949715#M17784</link>
      <description>&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;To log Spotify's player activity to the console:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;(check if this is working before anything)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;window.addEventListener(
  'message',
  function(e) {
    console.log(e);
  },
  false
);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 May 2025 18:43:45 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Spotify-iFrame-tracking-via-GTM-Any-code/m-p/6949715#M17784</guid>
      <dc:creator>tomasfn87</dc:creator>
      <dc:date>2025-05-09T18:43:45Z</dc:date>
    </item>
    <item>
      <title>Re: Spotify iFrame tracking via GTM. Any code?</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Spotify-iFrame-tracking-via-GTM-Any-code/m-p/6958262#M17831</link>
      <description>&lt;P&gt;Hey &lt;STRONG&gt;JoannaReyes&lt;/STRONG&gt;, please try my freshly developed solution (described under&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;Version 0.0.2&lt;/STRONG&gt;&lt;/EM&gt;). It's a complete Spotify Audio Tag, similar to YouTube and Vimeo Video Tags.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The repository link cannot be shared but it's Microsoft's repository service, you just need to add the path below:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;/tomasfn87/url-parser/blob/main/gtm/spotify-audio.json.md&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 12 May 2025 04:16:54 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Spotify-iFrame-tracking-via-GTM-Any-code/m-p/6958262#M17831</guid>
      <dc:creator>tomasfn87</dc:creator>
      <dc:date>2025-05-12T04:16:54Z</dc:date>
    </item>
    <item>
      <title>Re: Spotify iFrame tracking via GTM. Any code?</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Spotify-iFrame-tracking-via-GTM-Any-code/m-p/7059435#M18478</link>
      <description>&lt;P&gt;Thanks Thomas.&lt;/P&gt;&lt;P&gt;Is possible include Spotify Audio Title like a new parameter?&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jul 2025 07:33:56 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Spotify-iFrame-tracking-via-GTM-Any-code/m-p/7059435#M18478</guid>
      <dc:creator>carlosmdh</dc:creator>
      <dc:date>2025-07-21T07:33:56Z</dc:date>
    </item>
    <item>
      <title>Re: Spotify iFrame tracking via GTM. Any code?</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Spotify-iFrame-tracking-via-GTM-Any-code/m-p/7096499#M18667</link>
      <description>&lt;P&gt;Unfortunately not!&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;P&gt;The Spotify player is an iFrame HTML tag that opens &lt;A href="https://open.spotify.com" target="_blank"&gt;https://open.spotify.com&lt;/A&gt;, which means one can neither detect activity on it nor capture text from its HTML tags (track or episode title, artist, album or playlist name).&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;P&gt;I think it's possible to use some web scrapping tool to visit the &lt;A href="https://open.spotify.com" target="_blank"&gt;https://open.spotify.com&lt;/A&gt; URL and fetch this data later to enrich your Google Analytics reports.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Aug 2025 02:13:10 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Spotify-iFrame-tracking-via-GTM-Any-code/m-p/7096499#M18667</guid>
      <dc:creator>tomasfn87</dc:creator>
      <dc:date>2025-08-20T02:13:10Z</dc:date>
    </item>
  </channel>
</rss>

