Coder Social home page Coder Social logo

angulartics-adroll's Introduction

angulartics-adroll

Adroll plugin for Angulartics.

Install

NPM

First make sure you've read installation and setup instructions for Angulartics.

Then you can install this package either with npm or with bower.

npm

npm install angulartics-adroll

Then add angulartics.adroll as a dependency for your app:

require('angulartics')

angular.module('myApp', [
  'angulartics',
  require('angulartics-adroll')
]);

Please note that core Angulartics doesn't export the name yet, but it will once we move it into the new organization.

bower

bower install angulartics-adroll

Add the <script> to your index.html:

<script src="/bower_components/angulartics-adroll/dist/angulartics-adroll.min.js"></script>

Then add angulartics.adroll as a dependency for your app:

angular.module('myApp', [
  'angulartics',
  'angulartics.adroll'
]);

Create Adroll segments

alt tag

Track Adroll segments (programmatically)

After creating Adroll segment, you will get its segmentId (e.g. 'd531a9dd').

Now you can track the event programmatically.

module.controller('SampleCtrl', function ($analytics) {
  $analytics.eventTrack(null, { segments: 'd531a9dd' });
});

Documentation

Documentation is available on the Angulartics site.

Development

npm run build

License

MIT

angulartics-adroll's People

Contributors

bogdanmartinescu avatar mightymatth avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

foxio mightymatth

angulartics-adroll's Issues

Tracking segments not working when __adroll object generated in provider

When initializing Adroll script tag inside angular provider (and running it in run block) where it creates __adroll variable on window object, $analytics.trackEvent() function does not track anything.

This is how I initialize Adroll.

angular.module('myapp').provider('MyAdrollPixelManager', [
  function () {
    var config = {};

    this.config = function (newConfig) {
      angular.extend(config, newConfig);
    };

    this.$get = [
      '$window', '$log', '$analytics', 'AppConfig',
      function ($window, $log, $analytics, AppConfig) {

        return {
          config: config,
          createAdrollPixelScriptTag: createAdrollPixelScriptTag,
          trackMyEvent: trackMyEvent
        };

        function createAdrollPixelScriptTag() {
          if (!config.advId || !config.pixId) {
            $log.warn('No Advertiser ID and/or Pixel ID set to create Adroll Pixel script tag');
            return false;
          }

          adroll_adv_id = config.advId;
          adroll_pix_id = config.pixId;

          (function () {
            var _onload = function(){
              if (document.readyState && !/loaded|complete/.test(document.readyState)){setTimeout(_onload, 10);return}
              if (!window.__adroll_loaded){__adroll_loaded=true;setTimeout(_onload, 50);return}
              var scr = document.createElement("script");
              var host = (("https:" == document.location.protocol) ? "https://s.adroll.com" : "http://a.adroll.com");
              scr.setAttribute('async', 'true');
              scr.type = "text/javascript";
              scr.src = host + "/j/roundtrip.js";
              ((document.getElementsByTagName('head') || [null])[0] ||
                document.getElementsByTagName('script')[0].parentNode).appendChild(scr);
            };
            if (window.addEventListener) {window.addEventListener('load', _onload, false);}
            else {window.attachEvent('onload', _onload)}
          }());

          return true;
        }

        function trackMyEvent() {
          $analytics.eventTrack(null, { segments: AppConfig.adrollMyEventSegmentId || '' });
        }
      }
    ];
  }]).run([
  'MyAdrollPixelManager',
  function (MyAdrollPixelManager) {
    MyAdrollPixelManager.createAdrollPixelScriptTag();
  }
]);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.