justinhelmer
8/16/2017 - 9:54 PM

customView.refactor.js

export default BaseView.extend({
  // ...
  
  events: {
    'click .element': 'userAction'
  },
  
  tealium: function() {
    return {
      page_type: 'custom page type'
    };
  },
  
  // In an ideal world, the Tealium.view() call would be automatically handled by baseView, if MeW had proper lifecycle...
  // Unfortunately this approach will not work. The actual Tealium.view() call will need to happen in every single view,
  // since only the view will know when it's data is all ready (usually will be in postRender).
  postRender: function() {
    Tealium.view(this.tealium());
  },
  
  userAction: () => {
    // ...
    
    Tealium.link({
      event_name: 'custom event name'
    });
  },
  
  // ...
});