modified analytics code to analytics.js spec