Skip to content

Instantly share code, notes, and snippets.

@chhib
Last active May 26, 2016 09:03
Show Gist options
  • Select an option

  • Save chhib/a3b8d7d5ee81f889a91f5af3557d05b6 to your computer and use it in GitHub Desktop.

Select an option

Save chhib/a3b8d7d5ee81f889a91f5af3557d05b6 to your computer and use it in GitHub Desktop.
Keyword Provider Google Analytics plugin method for custom dimensions
<!-- Google Analytics Snippet -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-1234-5', 'auto');
// Add this before the send pageview call
ga('require', 'RoyAppKeywordProvider');
ga('send', 'pageview');
</script>
<!-- Google Analytics Snippet -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-1234-5', 'auto');
ga('send', 'pageview');
</script>
<!-- Roy App Keyword Provider snippet -->
<script>
(function (window) {
window['RoyAppKeywordProviderConfig'] = {
// Replace with your own Account ID
accountId: 'da967f53ae524ff98464a39c43d3a8gg',
plugin: {
customDimension: {
// Replace X with custom dimension index for Provided Keyword
keyword: 'dimensionX',
// Replace Y with custom dimension index for Provided Position
position: 'dimensionY',
// Replace Z with custom dimension index for Provided Search Engine
database: 'dimensionZ',
event: true
}
}
};
var s = window.document.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.src = '//cdn.royapp.com/kp.js';
var x = window.document.getElementsByTagName('script')[0];
x.parentNode.insertBefore(s, x);
}(window));
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment