Last active
December 7, 2017 10:38
-
-
Save dcvogi/e7854daa0c0aec2fec7a4141d8898fb5 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
(function trackGeolocation(){ | |
if (!window.navigator.geolocation) { | |
ga('send', 'event', 'browser support features', 'geolocation information', 'geolocation api is not supported'); | |
return; | |
} | |
function geoSuccess(position) { | |
ga('send', 'event', 'geolocation', 'position', position.coords.latitude + ',' + position.coords.longitude); | |
} | |
function geoError(positionError) { | |
ga('send', 'event', 'geolocation', 'error', positionError.message); | |
} | |
navigator.geolocation.watchPosition(geoSuccess, geoError); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment