Some qeries: ga.js vs analytics.js

2 replies
  • SEO
  • |
Hey guys,

I have been setting up some custom event tracking for a client's site (stuff like form submissions, form abandonment, video load, play pause etc). I setup everything using the old ga.js code. The client now insists we use the analytics.js code instead.

Does someone know of the best way to go about doing this? I mean I know I can have both ga.js and analytics.js codes in there and they will work fine, but having never used analytics.js before, I was wondeing what changes would be required in order to change all of my custom event tracking to analytics.js format (I guess _trackevent can not be used any more with this new version).

So I would really appreciate if someone could point me to some best parctices regarding this code changeover.

Regards,
Chandan
#analyticsjs #gajs #qeries
  • Brrainstormerr,

    You are right, the _trackEvent method is not supported in analytics.js. Instead, you pass the ga function the send command with event hit type. The snippet looks like this,

    ga('send', 'event', 'category', 'action', 'label', value); // value is a number.

    Note that if you use the above implementation, data will accumulate in the property you have set up to track analytics.js but not in your traditional ga.js profile. Conversely, if you leave event tracking the way it is, data will continue to accrue in your original account but not in the new one. You could apply both functions to whatever it is you are tracking and as soon as you are sure that there is data aggregating correctly, you could remove the old snippets and continue forward with the new.

    You may be able to find more guidance here,

    https://developers.google.com/analyt...yticsjs/events

    Best,

    Shawn
    Signature
    Outsource to the experts...

    We customize your Blog, eBook, Press Release and Sale Copy content with your message.

    {{ DiscussionBoard.errors[8013976].message }}
    • Profile picture of the author raviv
      Shawn has given a good explanation of what is to be done for event tracking with the new analytics.js script.

      The only thing you have to do now is to set up a new web property in your existing client's Google Analytics account and set up Tracking for it with analytics.js (the new Universal tracking).

      You can then embed this Universal tracking code along with the existing asynchronous ga.js tracking code on the same website.

      Both web properties (each with asynchronous and universal tracking scripts) will accumulate their respective accounts perfectly.
      {{ DiscussionBoard.errors[8015108].message }}

Trending Topics