Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to handle Google Tag Manager using dataLayer #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

penguinstampede
Copy link

I needed the script to work with GTM, so I added a bit of code to check for the dataLayer variable.
See https://developers.google.com/tag-manager/devguide

@mickey
Copy link
Owner

mickey commented Jun 10, 2014

Hey @penguinstampede thanks for the PR.
I'm not very familiar with GTM but according to the documentation the dataLayer can eventually be renamed.

Ideally I would detect the dataLayer whatever his name is. I searched a couple of minutes and didn't find any way to do this. I'll check againg tonight or t-row. If I don't, I'm inclined to accept your PR + add an option to pass the dataLayer.
What do you think?

Cheers

@phildpearce
Copy link

@mickey & @penguinstampede

Great plugin & a life saver!

But, needs some small refinements...

  1. Its strongly recommended to use eventNonInteraction (NOT nonInteraction)
  2. eventNonInteraction is incorrect set to "true" on the play click and percent played. Both these interactions should improve bounce rate. Pls change to:
    sendbeacon('play', false, currentTime); // PP changed to false
    sendbeacon('percent played', false, percent); // PP changed to false
  3. It is best to explicitly declare 'eventCategory': 'video' (even though this is the same as 'event': 'video').
  4. Please add 'videoId' this is needed for GA`s new server-side data append feature called dimension widening via CSV upload.

Updated example...
http://83.223.104.160/~searchph/_testing_script/__itv/gtm-code-examples/videojs-ga-f20f7478752c221ebde9a98e6602f1394d26c3e7/dist/videojs.ga.js

dataLayer.push({
'event': 'video',
'eventCategory': 'video', // Added
'eventAction': action,
'eventLabel': eventLabel,
'eventValue': value,
'eventNonInteraction': nonInteraction, // Changed
'videoId': '' // Added - CustomDimension - Used for server-side data append
});

Thanks

Phil.
GTM specialist
Useful ReadMe: http://bit.ly/gtmdevguide2

@tylerhunt
Copy link

Any updates on this?

@Gaebou
Copy link

Gaebou commented Oct 4, 2016

This js https://github.com/BrightcoveOS/videojs-ga-videocloud handles GTM. You just need to adjust labels to merge datas in analytics.

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

Successfully merging this pull request may close these issues.

6 participants