Last active
February 12, 2018 02:41
-
-
Save gthayer/320dd8e68d40217bb748 to your computer and use it in GitHub Desktop.
Google Analytics Plugin Wrapper
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
//Load GA Plugin. If unable to load, wait 50 milliseconds and attempt load again. | |
function providePlugin(pluginName, pluginConstructor) { | |
if (window.ga && document.body ) { | |
ga('provide', pluginName, pluginConstructor); | |
} | |
else { | |
window.setTimeout(function() { | |
providePlugin('main_analytics', gaEventsLoader); | |
}, | |
50); | |
} | |
} | |
// Plugin constructor. | |
function gaEventsLoader() { | |
//GA Plugin goes here | |
//__gaTracker( 'send', 'event', 'Category', 'Action', 'Label', 'Value', {'nonInteraction': 1} ); | |
} | |
// Register the plugin. | |
providePlugin('main_analytics', gaEventsLoader); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment