forked from frappe/erpnext
-
Notifications
You must be signed in to change notification settings - Fork 0
Adding Analytics and Social Buttons to Website
rmehta edited this page Jul 6, 2012
·
1 revision
You can add this in the Website Settings under "Startup Code"
Remember to set your correct account id
window._gaq = window._gaq || [];
window._gaq.push(['_setAccount', 'UA-XXXXXXX']);
window._gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www')
+ '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
In the startup section, add this:
(function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];
if(!d.getElementById(id)){js=d.createElement(s);js.id=id;
js.src="//platform.twitter.com/widgets.js";
fjs.parentNode.insertBefore(js,fjs);}})(document,"script","twitter-wjs");
In the page, in the onload method (in the code section) where you want your badge to appear:
wn.pages["page-name"].onload = function(wrapper) {
// render twitter button
window.twttr && window.twttr.widgets && window.twttr.widgets.load();
}
Add this in the "Startup" section in Website Settings
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
In your page (make sure to set your page name):
wn.pages["page-name"].onload = function(wrapper) {
// render plusone
window.gapi && window.gapi.plusone && window.gapi.plusone.go();
}