Below is code that can easily be inserted in to the CMS to five you user the option to quickly and easily add their Google Analytics Code:
GLOBALS.PHP MODULE CODE
Below is the Google Analytics Code to be inserted into the body just under <body> tag:
GOOGLE ANALYTICS CODE
Below is the code to be inserted in between he <head></head> tags to for Google Websmaster Verification andBing Webmaster Verification:
WEBMASTER CODE FOR HEAD
I hope everyone finds this useful. :p
- Developernator
GLOBALS.PHP MODULE CODE
- Code: Select all
<cms:editable name='analyticsAndTracking' label='Analaytics and Tracking' type='group' />
<cms:editable name='google_webamster_verification_code' label='Google Webmaster Verification Code' type='text' group='analyticsAndTracking' ></cms:editable>
<cms:editable name='ms_webamster_verification_code' label='Microsoft/Bing Webmaster Verification Code' type='text' group='analyticsAndTracking' ></cms:editable>
<cms:editable name='googleAnalyticsCode' label='Google Analytics Code' type='text' group='analyticsAndTracking' ></cms:editable>
<cms:editable name='googleAnalyticsDomain' label='Google Analytics Cookie Domain Name' type='text' group='analyticsAndTracking' ></cms:editable>
<cms:editable name='googleAnalyticsCookieName' label='Google Analytics Cookie Website Name' type='text' group='analyticsAndTracking' ></cms:editable>
<cms:editable name='googleAnalyticsCookieExpire' label='Google Analytics Cookie Expire Time' type='text' group='analyticsAndTracking' >3600</cms:editable>
Below is the Google Analytics Code to be inserted into the body just under <body> tag:
GOOGLE ANALYTICS CODE
- Code: Select all
<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', "<cms:get_custom_field 'googleAnalyticsCode' masterpage='globals.php' />", {
'cookieDomain': "<cms:get_custom_field 'googleAnalyticsDomain' masterpage='globals.php' />",
'cookieName': "<cms:get_custom_field 'googleAnalyticsCookieName' masterpage='globals.php' />",
'cookieExpires': <cms:get_custom_field 'googleAnalyticsCookieExpire' masterpage='globals.php' />
});
ga('require', 'displayfeatures');
ga('send', 'pageview');
</script>
Below is the code to be inserted in between he <head></head> tags to for Google Websmaster Verification andBing Webmaster Verification:
WEBMASTER CODE FOR HEAD
- Code: Select all
<meta name="google-site-verification" content="<cms:get_custom_field 'google_webamster_verification_code' masterpage='globals.php' />" />
<meta name="msvalidate.01" content="<cms:get_custom_field 'ms_webamster_verification_code' masterpage='globals.php' />" />
I hope everyone finds this useful. :p
- Developernator