Coder Social home page Coder Social logo

ntrack's Introduction

nTrack

Types of tracking which are used in Naukri

  • GA (GTM is internally triggering GA)
  • UBA
  • Performance - earlier called as newmonk
  • Error - called as nlogger
  • HeatMap
  • TNM

Tracking covered in nTrack- UBA, Performance, GA

Prerequisite

  • nLogger & uba script should be present in the index.html
<script type="text/javascript" src="//static.naukimg.com/s/0/0/j/nLoggerJB_v3.0.min.js"></script>
    <script type="text/javascript">
        window.nLogger && nLogger.init({ "tag": "revamped_jd", "nLogger": { "beaconUrl": "https:\/\/lg.naukri.com\/uba", "eventName": "newMonkError", "deviceType": "SERVER" }, "boomerang": { "logBW": false, "beaconUrl": "https:\/\/lg.naukri.com\/uba", "imageURL": "\/\/static.naukimg.com\/s\/0\/0\/i\/", "eventName": "newMonkPerformance", "deviceType": "SERVER" }, "tenantId": 1, "appId": 121, "userIP": "2088510594" });
    </script>
    <script>
        (function () {
            var queuedSuperProps = []; var queuedEvents = []; window.ub = { track: function (eventName, eventProps) { queuedEvents.push([eventName, eventProps]) }, register: function (properties) { queuedSuperProps.push(properties); } };
            var script = document.createElement("script"); script.async = true; script.src = "//static.naukimg.com/s/0/1/j/ub_v1.5.min.js"; script.onload = function () {
                ub.init({
                    beaconUrl: "https://logs.naukri.com/uba", queuedEvents: queuedEvents, queuedSuperProps: queuedSuperProps, tenantId: '1', autoTrack: false, blackList:
                        []
                });
            }; document.head.appendChild(script);
        }()); ub.register({ 'appId': 121, 'pageName': "jd", 'tenantId': '1', });
    </script>

How to use

  • Include the nTrack dependency in your project by adding the below mentioned line in package.json
"dependencies": {
    "ntrack": "git+http://gitdeployer:[email protected]/naukri-ui-dev/node-nTrack.git#v0.0.1-beta3"
}
  • Run npm install to install the added dependency

Implementation

  • Import nTrack library in the Root component
import 'ntrack/dist/nTrack_v1';
  • Now nTrack Library is available in the tracking variable which is present in the window object.
  • Initialize nTrack with the common parameters which are going to be used across the page (Not in the app) like Page name, jobId, src, Page index etc.
tracking.init({     searchId: 212,
                    pageIndex: 1,
                    jobPosition: 2,
                    jobId: 11111111,
                    src: 'demo'
                },
                {
                    pageName: 'demo page' 
                });
  • To perform the tracking use function doTracking
tracking.doTracking({
                uba: {
                    eventName: 'jobDetailsView',
                    keyNames: {
                        actionType: 'view',
                        errMsg: 'expired JD'
                    }
                }
            });

Syntax

doTracking(
    {
        uba:ubaObject,   //uba Object - Already populated Object
        performance:route,  //route Object- Only route object is needed by performance(boomlogger), performance creates its own object
        gaPageView:{
                  route:route,  //route Object
                  gaObj     // Additonal data fields
        },
        gaCustom:{
            defaultDataLayerObj:[array],
            extDataLayerObj:{
                params.....
            }
        }
    }
)

Example

tracking.doTracking({
  uba:{
    pageName:'applyHistory',
    eventName:'applyHistoryView',
    keyNames:{
      actionType:"view",
      referrer: this.props.route.previous
    }
  },
  gaPageView:{
      route:this.props.route,
        gaObj:{
            'spa-page-title': gaConfigData.title
          }
  },
  gaCustom:{
      defaultDataLayerObj:['spa-event','Certifications_Mobile','SaveSuccess','click'],
      extDataLayerObj:{
          'spa-event-value': 'AppPromo_Nav_button_click'
      }
  }
});

Functions

const init = (keyNames={},mainParams={}) => {
      commonUbaData = { ...keyNames };
      pageName=mainParams.pageName;
    };
 const doTracking = (trackingData) => {
      const uba = {
        pageName: pageName,
        eventName: trackingData.uba.eventName,
        keyNames: {
          ...commonUbaData,
          ...trackingData.uba.keyNames
        }
      };
      nTrack({
        ...trackingData,
        uba
      });
    };

Browser support

  • IE
  • Firefox
  • Chrome
  • Safari

ntrack's People

Watchers

Ashish Yadav avatar

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.