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

Google Analytics Tracking for CDN #568

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,12 @@ module.exports = function(grunt) {
css = css.replace(/font\//g, '../f/1/');
grunt.file.write('dist/cdn/video-js.css', css);

// Add CDN-specfic JS
jsmin = grunt.file.read('dist/cdn/video.js');
// GA Tracking Pixel (manually building the pixel URL)
jsmin += ';(function(i,w,n,e,l){l=w.location;i.src="//www.google-analytics.com/__utm.gif?utmwv=5.4.2&utmac=UA-16505296-2&utmn="+Math.floor(Math.random()*10e9)+"&utmhn="+e(l.hostname)+"&utmsr="+w.screen.availWidth+"x"+w.screen.availHeight+"&utmul="+(n.language||n.userLanguage)+"&utmp="+e(l.pathname);})(new Image(),window,navigator,encodeURIComponent);';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this render inside the VJS function (as a callback maybe)? I'm worried this will cause issues if the DOM isn't loaded. Also, the Image tag may need to be hidden so an invisible 1x1 GIF doesn't throw off the page it's rendered on...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The image element never gets added to the DOM actually, so, it shouldn't ever show up. So, I don't think it would matter if the DOM is loaded actually.
For some reason, image elements send off the request for the image as soon as their src is set.

grunt.file.write('dist/cdn/video.js', jsmin);

// Zip up into video-js-VERSION.zip
exec('cd dist && zip -r video-js-'+version.full+'.zip video-js && cd ..', { maxBuffer: 500*1024 }, function(err, stdout, stderr){

Expand Down