The time has come to get real-time statistics of listeners to your podcasts.
The problem has always been of who is listening to your own podcasts, how long are they listening for, when, and where are they stopping listening? Do they skip any part of the podcast?
Well, I wondered those same things, so I did something about it.
Introducing myPODstats!
This is the web application/code that finally gives you real-time stats to your podcasts, of what people are actually listening to.
The code that can be used as a simple standalone, or it's ready for you to hack and add to your bigger project where you need to know the listening habits of your podcast.
Buy Now for under $40
Please note: This code will only be able to capture audio that is played from a JS enabled web browser. It can not get stats from files that have already been downloaded, that are manually downloaded, or streamed or played through any other method.. This is only for when a visitor is listening on your site through a web browser, and this code is correctly implemented.
This code is designed to be hosted on your own server, where it can 'call home' every 30 seconds when audio is playing.
An example of the network traffic generated by myPODStats as it calls home.
Requirements:
JS, MySQL, PHP, jQuery (for the css selector.)
HTML Code Requirements: (Specifically if you are modifying the code)
The Javascript must be able to locate the HTML5 'AUDIO' tag via a CSS Class selector and then it must be able to find the ID of it, to that it can report the status of it to the server.
Installation Difficulty Level: Medium
Installation Time: Under 15 minutes)
Standard Installation:
At this stage it's a very manual setup, but it's very easy to get working.
- This example refers to '/pod_stats/', but it can be moved where you need it.
- Extract the provided zip file to /pod_stats/
- Create the database you wish to use if one doesn't already exist.
- Run the /db/create.sql in MySQL/MariaDB to create the required tables.
- Add the contents of the JS from the return_podcast_play_stats.js file to your template or page that contain the podcast files on it.
Or, add a script link to the JS source.
<script src="/js/return_podcast_play_stats.js"></script>
- Modify the JS according to your needs.
Depending on your installation location, you may need to edit line 45 so that the script knows where to POST the data to.
xmlhttp.open("POST","/pod_stats/collect.php",true);
Important: In the JS file, if you are not using WordPress, then comment out the WordPress function and uncomment the standard jQuery function. As seen in lines 12 and 15.
- Modify the config.php file to match your database settings.
- Test by pushing play on the audio file on the page.
Other Notes:
An example Audio tag that works:
<audio class="wp-audio-shortcode" id="audio-87-1_html5" preload="meta" style="width: 100%; height: 100%;" src="http://yourwebsite.com/podcast-player/87/coming-soon.mp3?_=1"><source type="audio/mpeg" src="http://yourwebsite.com/podcast-player/87/coming-soon.mp3?_=1"><a href="http://yourwebsite.com/podcast-player/87/coming-soon.mp3">http://yourwebsite.com/podcast-player/87/coming-soon.mp3</a></audio>
The script works by looking for HTML elements with the CSS class of "wp-audio-shortcode", and polling every 30 seconds to see if any of them are playing audio, it then calls home with the results.
To make sure that your script will find the correct audio tags give them a class of class="wp-audio-shortcode". You can change the CSS class name as required, but you must change the JS code to search for the correct class name.
Each audio tag must have it's own unique id as well.
WordPress Installation:
The initial stages are the same as the standard install, but it changes when dealing with WP specifics.
- Extract the provided zip file to /pod_stats/
- Edit the config.php file to match your database settings.
- Create the database you wish to use if one doesn't already exist.
- Run the /db/create.sql in MySQL/MariaDB to create the required tables.
WordPress continued:
While there are many ways of getting this going, this is just one easy way.
In your WordPress installation you may need to install following plugins: 'Seriously Simple Podcasting' and 'Insert Headers and Footers'.
After you have installed those plugins, you will need to do some minor additions.
Go to Settings, Insert Headers and Footers. Copy the contents from the zip file of /js/return_podcast_play_stats.js to the Footer. Save and close
Navigate to the settings of SS Podcasting. Under General, Change the Media player style to "Standard Compact Player".
Finished!
An alternative way without have to install the 'Insert Headers and Footers' plugin is to just insert in to your footer template code the following:
<script src="/js/return_podcast_play_stats.js"></script>
Depending on your installation location, you may need to edit line 45 so that the script knows where to POST the data to.
xmlhttp.open("POST","/pod_stats/collect.php",true);
Navigate to your_site.com/pod_stats/graph.php
The initial results will be currently empty, so try playing some audio on your website for a few minutes. Come back and see the result.
Support is available if you require further assistance.