Created
March 3, 2017 21:33
-
-
Save homm/b2d8e6a5f35811084894106f421d1f58 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.getDevicePixelRatio = function () { | |
var ratio = 1; | |
// To account for zoom, change to use deviceXDPI instead of systemXDPI | |
if (window.screen.systemXDPI !== undefined && window.screen.logicalXDPI !== undefined && window.screen.systemXDPI > window.screen.logicalXDPI) { | |
// Only allow for values > 1 | |
ratio = window.screen.systemXDPI / window.screen.logicalXDPI; | |
} | |
else if (window.devicePixelRatio !== undefined) { | |
ratio = window.devicePixelRatio; | |
} | |
return ratio; | |
}; | |
ga('create', '{{ settings.GOOGLE_ANALYTICS_TRACKING_ID }}', 'auto', opt_configObject); | |
ga('set', 'dimension2', getDevicePixelRatio().toFixed(2)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment