Tealium / integration-angularjs

Tealium Angular JS Integration
MIT License
17 stars 16 forks source link

Feature request: Does Tealium have a plugin for Single Page Web Apps based on React/Redux? #25

Open Srikanth-AD opened 7 years ago

tygavin commented 7 years ago

Nothing for React/Redux specifically (yet), but the pattern should be similar to the following (if you'd like to build and share),..

(1) Create a tracking wrapper function that accepts an eventName, and dataLayer object of key/values)

(2) If the utag.js file is loaded, fire utag.track( eventName, dataLayer ); // eventName is typically "view" for a content-viewed event

(3) If the utag.js file is not-yet-loaded, get the utag.js script and fire utag.track when it completes

For more reading:

// Wrapper function as seen inside of angular js integration
var track = function( ev, data ) {
        var data = data || tealiumData.getDataLayer( $location.path() );
        var ev = ev || "view";
        var src = config.script_src;

        if ( typeof utag == "undefined" ) {
          getScript( src, function(){
            utag.track( ev, data )
          })
        } else {
          utag.track( ev, data )
        } 
      };