I am trying create client side JS code which will call external JS server side script with some parameters, I was looking at Google Analitycs sample as this is exactly what I would like to achieve, however I don't really get how does it work...
(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-XXXXX-Y', 'auto');
ga('send', 'pageview');
I wonder how the server side script is parsing these elements.. I tried to reverse engineer http://www.google-analytics.com/analytics.js code but I don't get it..
Can I find somewhere simple snippet using same method which shows client - server asynchronous communication ?