Drupal statisitcs track file clicks - events

I have a Drupal website that has many smaple audio files on many pages. Some users come, listen to a sample, or listen to all of them and then leave.
But Google analytics does not track these clicks, even though in the option enabled:
Track downloads (clicks on file links) for the following extensions
7z|aac|arc|arj|asf|asx|avi|bin|csv|doc|exe|flv|gif|gz|gzip|hqx|jar|jpe?g|js|mp(2|3|4|e?g)|mov(ie)?|msi|msp|pdf|phps|png|ppt|qtm?|ra(m|r)?|sea|sit|tar|tgz|torrent|txt|wav|wma|wmv|wpd|xls|xml|z|zip
Which includes the mp3 files that I'm playing.
Then on Google Analytics in the Events section I can bearly see 3 mp3 downloads, and when I check my Apache log file, I have tens of clicks on mp3 files every day.
I'm using the soundmanager2 player that works as a link and with the help of Javascrip, Flash and CSS plays the mp3 files.
http://www.schillmania.com/projects/soundmanager2/
How could I track these clicks on the soundmanager player? If needed I can install another statistics module than google analytics...
Many thanks

Depending the display mode you use and the type of player, the tracking to integrate is different.
Display Media
Here no custom tracking needs to be added. The Google Analytics Drupal module with Track download links enabled does the job.
SoundManager player
If you use any of the available players, you need to add a custom javascript code and add a callback on the play event which is triggered on the first play of the SoundManager player(s).
The javascript looks as follows:
// Add callback on play event
threeSixtyPlayer.events.play = function() {
var url = this.url, // retrieve URL for active played MP3
file = url.substring(url.lastIndexOf('/')); // only keep filename of MP3
// Push an event to GA
_gaq.push(['_trackEvent', 'mp3', 'play', file.substring(1)]);
}
The event that is pushed to Google Analytics looks like this:
[mp3,play,Maid with the Flaxen Hair.mp3?uuid=525c67793bcd5]
Depending the used player, you should update and use to correct available instance.
SoundManager2 Page Player
pagePlayer.events.play = function() { ...
SoundManager2 UI 360
threeSixtyPlayer.events.play = function() { ...
SoundManager2 Inline player
inlinePlayer.events.play = function() { ...
SoundManager2 MP3 Basic player
basicMP3Player.events.play = function() { ...

Related

How do I detect when embedded Youtube video is playing?

UPDATE (July 2020): I was able to get a mostly working version of this. See my answer to the related question here.
In my angular Nativescript iOS app, I have a webview set up to play youtube videos. Following a method similar to this question here, I can get the youtube video to load and play automatically, using the Youtube Iframe API. But how do I detect when the video actually starts playing (after it is loaded)?
The Iframe API has events for this purpose, like "onStateChange". But, because my youtube code is "stuck" inside the webview, I am currently not able to read when events are fired from that webview.
In Nativescript, there is a nativescript-webview-interface plugin for this purpose, but I can't get it to work. I have put my code below. If that is the way to go, what is the correct code to get it working?
(I don't want to use the nativescript-youtube plugin because that brings in youtube's quotas, which are regularly shrinking. )
Code I Have Tried:
To get the youtube player to activate, I have put all of the relevant youtube code inside the webview. That works to play the video, but not yet to get the event of when the player starts playing. To do what I want to do, I need to have some way of inserting that code into my app WITHOUT trapping it in the webview. Or, have some way of communicating inside the webview.
To try to communicate with the webview, I have tried the nativescript-webview-plugin:
$ tns plugin add nativescript-webview-interface
html:
<web-view src="{{youtubeCode}}" #webView ></web-view>
ts:
import {WebView, LoadEventData} from "tns-core-modules/ui/web-view";
let webViewInterfaceModule = require('nativescript-webview-interface');
...
export class ...{
#ViewChild('webView') webView: ElementRef;
public youtubeCode = [code that youtube provides in its IFrame API]
ngOnInit(): void {
this.setupWebViewInterface();
}
setupWebViewInterface() {
let webView: WebView = this.webView.nativeElement;
this.oWebViewInterface = new webViewInterfaceModule.WebViewInterface(webView, '~/www/index.html');
this.youtubeListen()
}..
youtubeListen(){
this.oWebViewInterface.on('onStateChange', (eventData)=>{ //'onStateChange' is the event provided in the Youtube Iframe API
console.log('event data = ' + eventData) //***this is the key part I want to work.
});
}
RESULT: ERROR TypeError: undefined is not an object (evaluating 'this.webView.ios.constructor')
This is a problem in the plugin's index.ios.js file. If I comment out the offending line, then the errors go away, but then nothing happens
..

Google Sheets API: How to "publish to web" for embeddable sheet?

If I wanted to publish a Google Sheets spreadsheet so I could embed it on a page within an iframe, I would manually do the following:
Navigate to Google Drive
Open a spreadsheet
File > Publish To Web > Embed > Copy the generated iframe link into an html file
How would I programmatically achieve the above through the Google Sheets API using JavaScript on the front end? I'm generating spreadsheets on the fly in my application and want to immediately embed them on the page once created.
Once the sheet is created, I can dynamically create an iframe element with the necessary attributes (the sheets ID, among others). That throws an error. From this question, it looks like a sheet needs to have a published: true attribute or something, but that requires using the Drive API - I'm trying to avoid that. Is this possible to handle only through the Sheets API?
After searching through the entire Sheets API, googling, and just general soul-searching, I had no choice but to include the Drive API and use it to do my bidding. Here's the solution I came up with. Hope this helps someone else out there!
Used this script from Google for the client-side JS library in the index.html file:
<body>
...
<script type="text/javascript" src="https://apis.google.com/js/client.js"></script>
</body>
Then for the JS stuff:
// Cache the api's into variables.
var sheets = gapi.client.sheets;
var drive = gapi.client.drive;
// 1. CREATE NEW SPREADSHEET
sheets.spreadsheets.create({
properties: {
title: 'new-sheet'
}
}).then(function(newSpreadSheet) {
var id = newSpreadSheet.result.spreadsheetId;
// 2. PUBLISH SPREADSHEAT VIA DRIVE API
drive.revisions.update({
fileId: id,
revisionId: 1
}, {
published: true, // <-- This is where the magic happens!
publishAuto: true
}).then(function() {
// 3. DISPLAY SPREADSHEET ON PAGE VIA IFRAME
var iframe = [
'<iframe ',
'src="https://docs.google.com/spreadsheets/d/',
id,
'/pubhtml?widget=true&headers=false&embedded=true"></iframe>'
].join('');
// We're using jQuery on the page, but you get the idea.
$('#container').html($(iframe));
});
});
As you have concluded, it is not possible through the Sheets API today and is only possible through the Drive API (using the PATCH https://www.googleapis.com/drive/v3/files/fileId/revisions/revisionId request, documented at https://developers.google.com/drive/v3/reference/revisions/update).

How to listen to Flash video loading -- firefox-adds-on sdk?

I am writing adds-on to catch the url of youtube video, in the following Hierarchy :
// require tab.module.
// listen onTab.ready.
// Get the tab.url.
// If the url domain is youtube.
// Javascript request to get the direct .flv link.
// download the link.
But I figured out that other sites can embedd youtube videos.
I will really grateful to anyone give me hint about getting that embedded videos or the event which can catch them.

Windows Phone leave background music playing

My Windows Phone app was rejected because when I play a sound in the browser in my app it stops existing background music from playing (rejection issue 6.5.1).
How do I update my application to not stop background music?
My JavaScript is something like this:
var mySound = new Audio(soundpath);
Sound.play(mySound);
I could not find anything in Microsoft.Xna.Framework.Media that handles how the app handles browser sound, but maybe I missed something?
What you are looking for is from the xna soundeffect
Here is what I use and it works for me great for all my sound effects.
(You cannot use music with a 'soundeffect' object, as it will not pass the windows store qualifications. You have to use the MediaElement for music)
I can’t remember which you need but I have all these includes
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Media;
and this function
private static void LoadSoundEffect(string fileName, SoundEffectInstance mySound)
{
var stream = TitleContainer.OpenStream("Sounds/" + fileName);
var effect = SoundEffect.FromStream(stream);
FrameworkDispatcher.Update();
mySound = effect.CreateInstance();
}
If you use a SoundEffectInstance, you can start,pause,stop the soundeffect etc. without all the problems.
SoundEffect works as well, but I prefer the SoundEffectInstance.
Edit: If you use soundeffect, it will not effect the music being played.
I'm assuming that you are building a native Windows Phone app (.XAP) and then using a browser control to display your app content. If that is the case, you have checks that you will need to perform when the app is first opened. Below is a description of how to resolve that issue.
You will need to add this piece of code to your app (I suggest you check this every time your app loads/opens). Add a reference with the using statement as well for the Media.
if (Microsoft.Xna.Framework.Media.MediaPlayer.State == MediaState.Playing)
{
MessageBoxResult Choice;
Choice = MessageBox.Show("Media is currently playing, do you want to stop it?", "Stop Player", MessageBoxButton.OKCancel);
if (Choice == MessageBoxResult.OK)
mediaElement1.Play();
}
If the user allows or disallows the media to be played you must put checks in your JavaScript for this. You will fail certification again if the user says "Cancel" and you play music anyway.
There is more information on the topic here.

Play multiple audio streams in WP7 PhoneGap

I new to wp7 phonegap environment and I am having issues playing audio files. I am able to play one audio file as many times possible but cant play another audio of different instance, which is a requirement for my on-going project.
Any help?
you can use a phonegap native sound system
the javascript code for it is
src1="sounds/cartoon001.mp3"
src2="sounds/cartoon002.mp3"
var soundObj1 = new Media(src1,onSuccess,onError);
var soundObj2 = new Media(src2,onSuccess,onError);
soundObj1.play();
soundObj2.play();
also kindly check that mp3 files are supported in mobile.
you have to write a overriding functions for onSuccess and onnError.
javascript function to play:
playAudioFile("spellsound");
function playAudioFile(id){
var s=document.getElementById(id);
s.play();
}
html page<audio id='m' src='audio/baby/M.mp3'></audio>
or u can load src to audio tag by id in DOM

Resources