You'll have to bear with me here as I'm kind of feeling my way when it comes to module coding; I've been looking for a way to use Flowplayer's Analytics plugin with Drupal so I can track my video events independently of my regular page tracking. So far I've come up with the following:

Adding this code to under line 61:

   $form['swftools_flowplayer3_files']['flowplayer3_google_analytics_plugin'] = array(
    '#type' => 'textfield',
    '#default_value' => variable_get('flowplayer3_google_analytics_plugin', ''),
    '#title' => t('Google Analytics Plugin'),
    '#description' => t('The path to the Flowplayer3 Google Analytics plugin.'),
    '#size' => 50,
  $form['swftools_flowplayer3_files']['flowplayer3_google_analytics_accountnum'] = array(
    '#type' => 'textfield',
    '#default_value' => variable_get('flowplayer3_google_analytics_accountnum', ''),
    '#description' => t('Google Analytics Account Number'),
    '#size' => 20,

Adding this code to swftools_flowplayer3.module under line 229:

  if (variable_get('flowplayer3_google_analytics_plugin', '')) {
    $flowplayer['plugins']['gatracker']['url'] = variable_get('flowplayer3_google_analytics_plugin', '');
    $flowplayer['plugins']['gatracker']['labels']['start'] = "Start";
    $flowplayer['plugins']['gatracker']['labels']['play'] = "Play";
    $flowplayer['plugins']['gatracker']['labels']['pause'] = "Pause";
    $flowplayer['plugins']['gatracker']['labels']['resume'] = "Resume";
    $flowplayer['plugins']['gatracker']['labels']['seek'] = "Seek";
    $flowplayer['plugins']['gatracker']['labels']['stop'] = "Stop";
    $flowplayer['plugins']['gatracker']['labels']['finish'] = "Finish";
    $flowplayer['plugins']['gatracker']['labels']['mute'] = "Mute";
    $flowplayer['plugins']['gatracker']['labels']['unmute'] = "Unmute";
    $flowplayer['plugins']['gatracker']['labels']['fullscreen'] = "Full Screen";
    $flowplayer['plugins']['gatracker']['labels']['fullscreenexit'] = "Full Screen Exit";
    $flowplayer['plugins']['gatracker']['trackingMode'] = "AS3";
    $flowplayer['plugins']['gatracker']['googleId'] = variable_get('flowplayer3_google_analytics_accountnum', '');
    $flowplayer['plugins']['gatracker']['debug'] = false;                                                                

I would really appreciate it if anyone could suggest a way I can implement this without having to amend the module's code directly. Like I say I'm pretty much working this out as I go along so any suggestions would be great..


sylvaticus’s picture

hello, I have the same need (tracking of video displayed).. can you elaborate on how you managed to get it working? Are you refering to this plugin ?

It would be nice to have this "patch" in the module..

Thank you :-)

radiorel’s picture

Yes that's the right one - I put the into my sites/all/libraries/flowplayer3 folder with the rest of the flowplayer libraries, then 'patched' the two files as above. I've just checked and my line numbers are slightly out on the latest version of SWF Tools, but as long as it's roughly in the right place it should still work.

The first code snippet adds two new form fields under the 'player and plugin files' fieldset within the Flowplayer 3 options (looks something like this) - you need to add the filename and your Google Analytics account number in here. The second snippet modifies the Flowplayer embed code so it includes the analytics plugin when it's generated on the page. The tracking should then come up in the 'event tracking' section of your analytics report (not in the usual page tracking bit).

It definitely would be nice to have this in the module itself - does anyone know if / how this would be possible? I don't really have any experience with module coding so don't know how these things work.


LetUsBePrecise’s picture

Not sure why it is not working for me.

It is giving me an error:
200: Error occurred in a plugin: gatracker. Google Analytics account ID not specified. Look it up in your Analytics account. the format is UA-XXXXXX-N

I can confirm that I've correctly updated the analytic account ID in flowplayer plugin settings and I can also see the value in db variable flowplayer3_google_analytics_accountnum

Any idea what could be the reason?


radiorel’s picture

Where are you seeing the error - is it appearing as a Drupal error box at the top of the page or is it appearing within the Flowplayer player itself?

LetUsBePrecise’s picture

It was inside flowplayer.


$flowplayer['plugins']['gatracker']['googleId'] = variable_get('flowplayer3_google_analytics_accountnum', '');


$flowplayer['plugins']['gatracker']['accountId'] = variable_get('flowplayer3_google_analytics_accountnum', '');

resolved my issue.

Do I need any other settings for tracking events in google analytics?

radiorel’s picture

Glad it's resolved. Looks to me like Flowplayer must have changed the parameter name from 'googleId' to 'accountId' in the latest release. I'm using flowplayer-analytics-3.2.1 on my site but when I switch it to 3.2.2 I get an 'error #1069' which looks like it might be being caused by the same problem.

You shouldn't need to set anything else for the tracking events since they're all added in the module code snippet above (as long as they haven't changed the names of any of them in 3.2.2 as well...). I usually find events begin appearing on Google Analytics within a few hours of enabling the event tracking.