I have already built a site with backbone marionette and now I am trying to use Google Tag manager to add the tracking. But I have no idea how to configure GTM, in order to listen page change and button click event.
相关问题
- Backbone.js PushState routes .htaccess only workin
- Updating a LayoutView's Model
- Disable Backbone.js hashes entirely, but keep push
- Set API key with embed API google analytics
- Integrate Firebase Analytics with Xamarin Android
相关文章
- How to correctly use google analytics measurement
- Get all models in backbone collection where attrib
- How can I dynamically set a className for a Backbo
- Android referral tracking not working with Google
- Universal Analytics Measurement Protocol respond 2
- Nesting Views within Views in backbone js
- Profiling the Performance of a Google App Script
- Backbone-relational hasmany best practices
There is a bit of fiddling required there. Tag manager uses a data structure called
dataLayer
. It's an array, that you can add events to. So to configure tag manager, you need to add a snippet to HTML page of the application as in any other case. On top of it, you have to initialise the dataLayer array but you need to make sure, that the code initialising this variable is invoked before the snippet. So here is the full example in the head of the index.html page (in one page app):The function called
loadProductDetails
is an example on how you push the events to Google servers - you just need to add an object to the dataLayer array.Dan Russel wrote a full blog post about it, together with explanation how to setup the macro for extracting the events.
And there is a bit of documentation on this as well here
Clicks are up to you to set up listening events and track manually from views. Page views can be tracked like this: