{"id":423,"date":"2012-04-27T10:20:16","date_gmt":"2012-04-27T14:20:16","guid":{"rendered":"http:\/\/www.deadcodersociety.org\/?p=423"},"modified":"2012-04-29T13:48:20","modified_gmt":"2012-04-29T17:48:20","slug":"building-a-streaming-radio-station-part-3-streaming-analytics","status":"publish","type":"post","link":"http:\/\/www.deadcodersociety.org\/blog\/building-a-streaming-radio-station-part-3-streaming-analytics\/","title":{"rendered":"Building a Streaming Radio Station, Part 3: Streaming Analytics"},"content":{"rendered":"<figure id=\"attachment_441\" aria-describedby=\"caption-attachment-441\" style=\"width: 480px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.deadcodersociety.org\/blog\/wp-content\/uploads\/2012\/04\/stkfm.png\"><img loading=\"lazy\" class=\"size-large wp-image-441\" src=\"http:\/\/www.deadcodersociety.org\/blog\/wp-content\/uploads\/2012\/04\/stkfm-1024x785.png\" alt=\"\" width=\"480\" height=\"367\" srcset=\"http:\/\/www.deadcodersociety.org\/blog\/wp-content\/uploads\/2012\/04\/stkfm-1024x785.png 1024w, http:\/\/www.deadcodersociety.org\/blog\/wp-content\/uploads\/2012\/04\/stkfm-300x230.png 300w, http:\/\/www.deadcodersociety.org\/blog\/wp-content\/uploads\/2012\/04\/stkfm.png 1402w\" sizes=\"(max-width: 480px) 100vw, 480px\" \/><\/a><figcaption id=\"caption-attachment-441\" class=\"wp-caption-text\">stk.fm in action<\/figcaption><\/figure>\n<p>This is the final segment of my blog post about building a streaming radio station. Part 1 can be found <a href=\"http:\/\/www.deadcodersociety.org\/blog\/building-a-streaming-radio-station-part-1-icecast-mpd-and-python\/\" target=\"_blank\">here<\/a>, and part 2 can be found <a href=\"http:\/\/www.deadcodersociety.org\/blog\/building-a-streaming-radio-station-part-2-iframe-hacks-and-jplayer\/\" target=\"_blank\">here<\/a>.<\/p>\n<h1>Streaming Analytics<\/h1>\n<p>The station was just about ready to launch. Just one part was missing &#8211; analytics. It&#8217;s difficult to keep track of analytics for streaming audio simply due to the nature of the content. I couldn&#8217;t find an existing solution that fit my needs, so I built my own.<\/p>\n<p>I was only majorly concerned with a few different metrics &#8211; namely, how many people were listening, what they listened to, and how long they listened. I added a new table to the MySQL database that the rest of the site had been running on to keep track of these metrics. In the player&#8217;s check-in process, I added an include for a script which would register analytics. This script would add or update a row for that particular session (identified by PHP session ID) which stored:<\/p>\n<ul>\n<li>Timestamps for the first and most recent check-ins<\/li>\n<li>The first and most recently listened to songs<\/li>\n<li>The number of seconds of music that were streamed<\/li>\n<\/ul>\n<p>It wasn&#8217;t possible to derive the length of time the user was actually listening from the start and end times, as the player wouldn&#8217;t check in if the stream was paused. However, I of course knew that the player checked in every five seconds, so I could use this to get a fairly close approximation of how much audio was actually streamed.<\/p>\n<p>&nbsp;<\/p>\n<p>Between now and the time that I started writing this series of blog posts, I unfortunately had to take stkbuzz down entirely. However, I do intend on making the previously mentioned Python script open source soon &#8211; I&#8217;d hate to see it go to waste!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The station was just about ready to launch. Just one part was missing &#8211; analytics.<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_links_to":"","_links_to_target":""},"categories":[4],"tags":[25,21],"aioseo_notices":[],"_links":{"self":[{"href":"http:\/\/www.deadcodersociety.org\/blog\/wp-json\/wp\/v2\/posts\/423"}],"collection":[{"href":"http:\/\/www.deadcodersociety.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.deadcodersociety.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.deadcodersociety.org\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"http:\/\/www.deadcodersociety.org\/blog\/wp-json\/wp\/v2\/comments?post=423"}],"version-history":[{"count":11,"href":"http:\/\/www.deadcodersociety.org\/blog\/wp-json\/wp\/v2\/posts\/423\/revisions"}],"predecessor-version":[{"id":443,"href":"http:\/\/www.deadcodersociety.org\/blog\/wp-json\/wp\/v2\/posts\/423\/revisions\/443"}],"wp:attachment":[{"href":"http:\/\/www.deadcodersociety.org\/blog\/wp-json\/wp\/v2\/media?parent=423"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.deadcodersociety.org\/blog\/wp-json\/wp\/v2\/categories?post=423"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.deadcodersociety.org\/blog\/wp-json\/wp\/v2\/tags?post=423"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}