In a backbone.js app, where should I put an event tracking tag for "visited site"?

111 Views Asked by At

I'm using Mixpanel, and I need one general event anytime anyone visits the site. Basically it should fire once per 'hit', or be the same as a visit in Google Analytics.

I tried adding it to my index.html file, but the problem was it seems to fire many more times than one per visit.

My sense is to put it in my App.start(); function. Is this a good place, or where would be the best place to put the event tracker?

1

There are 1 best solutions below

0
On

Put this line of code into your view

initialize: function() {
        this.$el.off();
    },

Resource: https://github.com/datomnurdin/izify-template/blob/master/js/views/home/HomeView.js