Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Upgrade Google Analytics Classic to Universal #298

Open
grantkemp opened this issue May 6, 2016 · 8 comments
Open

Upgrade Google Analytics Classic to Universal #298

grantkemp opened this issue May 6, 2016 · 8 comments

Comments

@grantkemp
Copy link

Currently the code in Analytics 3.2.9 seems to be using Analytics Classic - which is no longer advocated by Google. It should be updated to Google analytics univesal.

The only place I can see the bridge is here:
https://github.com/flowplayer/flash/blob/1caea54d3e7fa66b6496d556998052507a6d05a4/core/test/analytics.html

Is there any other locations that I haven't looked.?

If so -then I can suggest a good way to implement it that would be backwards compatible with existing legacy versions of Flow player and allow full use of the latest Google Analytics features.

@grantkemp
Copy link
Author

grantkemp commented May 6, 2016

It actually looks pretty easy to do as the code is structured nicely.

I think I can do a fix easilty and share it back. How Do I compile just the SWF plugin for analytics? I can't see anything in the readme for the project or in the Flowplayer docs.

@danrossi
Copy link
Contributor

danrossi commented May 6, 2016

They use the swc libraries of the GA code.

Original project was here

https://code.google.com/archive/p/gaforflash/

New project

https://github.com/zwetan/as3-universal-analytics

@grantkemp
Copy link
Author

grantkemp commented May 6, 2016

@danrossi ah - good shout. Is that big thing to do ? I was looking at doing it via the Bridge instead of using Measurement protocol.

It sounds like it would be the easiest option and ideal just to update the flash plugin to use universal as you say above.

@grantkemp
Copy link
Author

Just had a look - and unfortunately flash is not my strong point.
I know GA and Measurement protocol really well - so I can advise on the implementation if someone can do the Flash piping.

@zwetan
Copy link

zwetan commented May 6, 2016

by quickly looking at the sources it seems the analytics is done trough a plugin
https://github.com/flowplayer/flash/tree/master/plugins/analytics

I would suggest to create another analytics plugin (maybe? I'm not sure)
keeping the same structure/logic
but replacing com/google/analytics packages with the ones of as3-universal-analytics

then you would have to change the logic and api calls in org/flowplayer/analytics
(maybe another name? org/flowplayer/uanalytics or whatever to not confuse the 2 plugins)

in the main class GoogleTracker (maybe rename that too?)

for example

import libraries.uanalytics.tracking.AnalyticsTracker;
import libraries.uanalytics.tracker.WebTracker;

public class GoogleTracker extends Sprite implements Plugin {

//...
private var _tracker:AnalyticsTracker; // ideally use the interface

private function instantiateTracker():void {

    try {
        _tracker = new WebTracker( "UA-12345-67" ); // for web
        //_tracker = new AppTracker( "UA-12345-57" ); // for AIR
        // or any custom tracker/sender that implement the interface

        // more logic if needed

    } catch(e:Error) {
        _model.dispatchError(PluginError.ERROR, "Unable to create tracker: " + e);
    }
}

}

private function doTrackEvent(eventName:String, trackViewDuration:Boolean = false, event:ClipEvent = null):void {

    if (_tracker == null) {
        instantiateTracker();
    }

    var clip:Clip = Clip(event ? event.target : _player.currentClip);
    var time:int = trackViewDuration ? (_viewDurationMillis / 1000) : int(_player.status ? _player.status.time : 0);

    // follow the doc from the interface 
    // eg. event( category:String, action:String, label:String = "", value:int = -1 ):Boolean;
    _tracker.event( category, eventName, clip.completeUrl + (clip.isInStream ? ": instream" : ""), time );
}

see interface libraries.uanalytics.tracking.AnalyticsTracker

from that it's writing logic for the configuration and other custom settings you may need.

@danrossi
Copy link
Contributor

danrossi commented May 7, 2016

It seems it needs a complete refactor to use the new library.

@zwetan
Copy link

zwetan commented May 7, 2016

it is a different library implementing a different protocol
even if it is still Google Analytics

@grantkemp
Copy link
Author

yes I tried to have a go this weekend.

so far after about 5hours, ihave got my head round it but am fighting against my lack of knowledge on flash to really progress.

i think the ideal method - is just to update the _gaq calls and change them to ga( calls via the Javascript bridge until someone who knows more flash can find time to update.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants