CardinalPath / gas

Google Analytics on Steroids. A Google Analytics implementation with more power features.
Other
593 stars 78 forks source link

Using a different label for youtube video tracking #44

Closed pietschy closed 10 years ago

pietschy commented 11 years ago

Hi all,

Is there a way for me to provide a label other than the youtube url? Ideally I'd like to get the label from a data attribute if possible.

I initially tried adding a hook for you tube events as follows but to no avail:

    _gas.push(['_addHook', '_gasTrackYoutube', function(options){
        // do stuff...
        return options_with_different_label;
    }]);

I though of using the _trackEvent hook but that'd get a bit ugly with switches on the category and I'm not sure how I could get to the iframe data attributes.

Other than that it looks like the only option would be to add a some kind of hook to the _ytStateChange function that can use the event['target'] to return a different label.

Any help greatly appreciated. Cheers

tomfuertes commented 10 years ago

Pull request welcome if you'd like to add/set an options parameter (https://github.com/CardinalPath/gas/blob/master/src/plugins/youtube.js#L16) and get it into core. Until then, overriding the _trackEvent hook is your best bet.

Either that or doing your own build and modifying the label here: https://github.com/CardinalPath/gas/blob/master/src/plugins/youtube.js#L36