Class

CStatApp

(abstract) CStatApp()

Constructor

abstract new CStatApp()

Statistics Application base class for singletons. This is the abstract Class Customizer that must be implemented by at least one singleton.
It is made of a static factory CStatApp.factory (to be defined in Customization JS), a static singleton accessor CStatApp.getInstance and a set of instance methods to be implemented or overridden in derived classes.
It provides a built-in access to two children classes singletons: CStatApp.base and CStatApp.extend (see below).

Properties:
Name Type Description
base CStatApp

Base class singleton, for outside class access to common behaviors.

extend CStatApp

Extended class singleton, for outside class access to page behaviors.
Preferrably access it with CStatApp.getInstance().
Can be the same than base in case of Single Level of Inheritance.
Created by CStatApp.factory

Tutorials:

Methods

static factory(nameopt)

Factory of child class singleton, to be defined in Customization JS.

  • When name is not provided, it creates the commone CStatApp.base singleton.
  • From a non-empty name, it creates the specialized CStatApp.extend singleton.

    Parameters:
    Name Type Attributes Description
    name string <optional>

    The name of the application, create the base class when not provided.

    Tutorials:
  • static getInstance() → {CStatApp}

    Statistics Application's Page singleton accessor.

  • When base singleton still not created, call CStatApp.factory(), so with no name => CStatApp.base is created and returned.
  • When base singleton created, but extend one still not, call CStatApp.factory(CStatApp.base.getName())

    CStatApp.base if it was still not created, CStatApp.extend otherwise.

    CStatApp
  • activate()

    Trackers activation (i.e. markers injection), triggered on DOMContentLoaded.
    By default: activate search clicks tracking, then other events tracking (Download, Navigation, Exit, Action)
    Note: calling it twice or more is useless without reinitialisation of tracker objects.

    Example
    Super.activate=this.activate;
    this.activate=function()
    {
       Super.activate.call(this);
       // Raise GTM event 
       window.dataLayer=window.dataLayer||[];
       dataLayer.push({event:'pageActivation'});            
    };

    activateOnLoad()

    Activations to perform once page loaded.
    Can be overriden in completion to On Load option, which already recalls CStatApp.activate
    By default: does nothing.

    Example
    this.activateOnLoad=function()
    {
       // Wait for lazy loadings
       stat_link.waitRefresh();
    };

    beginSalesOrder(fp)

    Sales order initialization.
    By default: does nothing

    Parameters:
    Name Type Description
    fp string

    Final path , as computed for Perimeter mapping (Initial or Customized or Remainder)

    Example
    this.beginSalesOrder = function(fp)
    {
        //TODO: Sales order
    };

    beginSalesProduct(pdt, an)

    Product initialization.
    By default: does nothing

    Parameters:
    Name Type Description
    pdt stat_sales.Product

    Product object

    an Array.<object>

    List of nodes describing this Product

    Example
    this.beginSalesProduct = function(pdt, an)
    {
        //TODO:  
    };

    beginSearch(fp)

    Search tracking initialization.
    By default: does nothing

    Parameters:
    Name Type Description
    fp string

    Final path , as computed for Perimeter mapping (Initial or Customized or Remainder)

    Example
    this.beginSearch = function(fp)
    {
        //TODO:
    };

    beginVideo(fp)

    Entry point before videos collection
    By default: does nothing.

    Parameters:
    Name Type Description
    fp string

    Final path, as computed for Perimeter mapping (Initial or Customized or Remainder)

    Example
    Super.getVideoTheme = this.getVideoTheme;
    this.beginVideo = function(fp)
    {
        //TODO:
    };

    beginVisitor(fp)

    Visitor tracking initialization.
    By default: does nothing.

    Parameters:
    Name Type Description
    fp string

    Final path , as computed for Perimeter mapping (Initial or Customized or Remainder)

    Example
    this.beginVisitor = function(fp)
    {
        //TODO:
    };

    endSalesOrder(fp)

    Sales order completion & checking.
    By default: does nothing

    Parameters:
    Name Type Description
    fp string

    Final path , as computed for Perimeter mapping (Initial or Customized or Remainder)

    Example
    this.endSalesOrder = function(fp)
    {
        //TODO:  
    };

    endSalesProduct(pdt, an)

    Product completion & checking.
    By default: does nothing

    Parameters:
    Name Type Description
    pdt stat_sales.Product

    Product object

    an Array.<object>

    List of nodes describing this Product

    Example
    this.endSalesProduct = function(pdt, an)
    {
        //TODO:  
    };

    endSearch(fp)

    Search tracking completion & checking.
    By default: does nothing

    Parameters:
    Name Type Description
    fp string

    Final path , as computed for Perimeter mapping (Initial or Customized or Remainder)

    Example
    this.endSearch = function(fp)
    {
        //TODO:
    };

    endVideo(fp)

    Entry point after videos collection
    By default: does nothing.

    Parameters:
    Name Type Description
    fp string

    Final path, as computed for Perimeter mapping (Initial or Customized or Remainder)

    Example
    this.endVideo = function(fp)
    {
        //TODO: 
    };

    endVisitor(fp)

    Visitor tracking completion & checking.
    By default: does nothing.

    Parameters:
    Name Type Description
    fp string

    Final path , as computed for Perimeter mapping (Initial or Customized or Remainder)

    Example
    Super.getVideoTheme = this.getVideoTheme;
    this.endVisitor = function(fp)
    {
        //TODO:
    };

    getAccountPath(p) → {string}

    Retrieve the Path to be compared with Production Path Root.
    In case of additional leading folders, don't forget to start by /
    By default: return unchanged path.

    Parameters:
    Name Type Description
    p string

    Initial path

    Deprecated:

    Custom path

    string

    getCookie(cookieName) → {string}

    Shortcut to retrieve cookie value.
    By default: call stat_data.getCookie
    Can be overriden to transform the value, for example in case of JSON string.

    Parameters:
    Name Type Description
    cookieName string

    Name of stored cookie

    The cookie value, empty string if not found

    string

    getExtraChapter() → {string}

    Allows changing in Page names the separator used to replace :: when the number of chapter is greater than 3.
    It is used only by Page names, so it doesn't impact any click nor event name, except when they embed Page name with %x: in this case the Extra Chapter is used to replace all chapter separators.
    By default: "_" in all Page names

    Changed separator

    string
    Example
    // Use | as extra chapter separator
    this.getExtraChapter = function()
    {
        return '|';
    };

    getExtraLeaf() → {string}

    Declare a value to be removed from an ATI page tag name when found as leaf name (when there are chapters).
    It is used only by Page names, so it doesn't impact any click nor event name.
    By default: empty string (no removal).

    Leaf value to be removed.

    string
    Example
    // Remove '::undefined' from Page Names
    this.getExtraLeaf = function()
    {
        return 'undefined';
    };

    getLevel2Path(p) → {string}

    Retrieve the path name to be compared with Perimeter Path.
    By default: return unchanged path.

    Parameters:
    Name Type Description
    p string

    Final path (Initial or Customized or Remainder)

    Deprecated:

    Final path modified

    string

    getLinkName(href, type) → {string}

    Control default click names for links when nothing specified in configuration NAME column.
    By default: return stat_link.getLinkNameNc

    Parameters:
    Name Type Description
    href string

    URL of link

    type string

    Click tag type ('N', 'S', 'T', 'A')

    Click name

    string
    Example
    Super.getLinkName=this.getLinkName;
    this.getLinkName=function(href, type)
    {
       // By default, return the target path for Navigation links  
       return ((type==='N' && href)? getUrlArray(href)[3]:Super.getLinkName.call(this, href, type);          
    };

    getLinkNodeName(node, type, eopt) → {string}

    Retrieve the click tag name corresponding to a given node.
    By default: return stat_link.getLinkNodeNameNc

    Parameters:
    Name Type Attributes Description
    node object

    The node from which click tag is raised.

    type string

    Click tag type ('N', 'S', 'T', 'A', 'IS').

    e object <optional>

    Current event.

    Click tag name

    string
    Example
    Super.getLinkNodeName=this.getLinkNodeName;
    this.getLinkNodeName=function(node,type,e)
    {
        // Use a library function std_doc.getDocName for all Downloads with no name configured, mother call for all other cases
        return (type === 'T' && !stat_link.getNodeNamePattern(node))? std_doc.getDocName(node) : Super.getLinkNodeName.call(this,node,type,e);
    };

    getName() → {string}

    Retrieve application's name (to be implemented in inherited classes), for Multiple Levels of Inheritance.
    By default: Throw an error
    It can deduct the application name itself, or rely on the previous calls to CStatApp.setPathName

  • Called by CStatApp.getInstance
  • Never called by Single Level of Inheritance model (so no need to define it).

    Application name

    string
    Example
    this.name='';
    this.getName=function(){return this.name;};
  • getNodeLabel(node) → {string}

    Allows controlling the way a text is retrieved from a node when # is used in an event name
    Called by stat_link.getNameChapter. It doesn't change other values extraction.
    By default: call stat_dom.getNodeText, then remove all ? and & in text (if any)

    Parameters:
    Name Type Description
    node object

    DOM node

    node label

    string
    Example
    Super.getNodeLabel=this.getNodeLabel;
    this.getNodeLabel=function(node)
    {
       // Always return 'nolabel' if no text  
       return (Super.getNodeLabel.call(this, node) || 'nolabel');          
    };

    getPerimeterPath(p) → {string}

    Retrieve the Path to be compared with Perimiter Path Root, by adding virtual folders or move/remove existing ones.
    In case of additional leading folders, don't forget to start by /
    By default: return unchanged path.

    Parameters:
    Name Type Description
    p string

    Final path (Initial or Customized or Remainder)

    Final path modified

    string
    Example
    this.getPerimeterPath=function(p)
    {
        // Add app URL parameter value  as a virtual folder, 'other' if not exist
        return '/'+(getPageParam('app')||'other')+p;
    };

    getProductionPath(p) → {string}

    Retrieve the Path to be compared with Production Path Root, by adding virtual folders or move/remove existing ones.
    In case of additional leading folders, don't forget to start by /
    By default: return unchanged path.

    Parameters:
    Name Type Description
    p string

    Initial Path (Original path shorten with common path)

    See:

    Custom path

    string
    Example
    this.getProductionPath=function(p)
    {
        // Add hostname extension containing country as a virtual folder
        return '/'+window.location.hostname.split('.').slice(-1)[0]+p;
    };

    getSearchPos(node)

    Retrieve result click position.
    By default: return stat_search.getSearchPosNc

    Parameters:
    Name Type Description
    node

    Clicked result link node

    Computed node position

    Example
    Super.getSearchPos = this.getSearchPos;
    this.getSearchPos = function(fp)
    {
        var pos=Super.getSearchPos.call(this, node);
        //TODO: Modify default
    };

    getVideoPattern(fp)

    Allows controlling the pattern used to recognize a YouTube video.
    By default: return nothing, so that default pattern 'www.youtube.com/embed/' is used

    Parameters:
    Name Type Description
    fp string

    Final path, as computed for Perimeter mapping (Initial or Customized or Remainder)

    Video pattern to be found in iframe.src. If empty, default will be used.

    Example
    this.getVideoPattern = function(fp)
    {
        return 'www.youtube.com/embed/';
    };

    getVideoTheme(fp)

    Retrieve current video Theme
    By default: return stat_video.getThemeNc

    Parameters:
    Name Type Description
    fp string

    Final path, as computed for Perimeter mapping (Initial or Customized or Remainder)

    Computed Theme

    Example
    Super.getVideoTheme = this.getVideoTheme;
    this.getVideoTheme = function(fp)
    {
        var defTheme=Super.getVideoTheme.call(this, fp);
        //TODO: Modify default
    };

    initSalesProducts(fp)

    Sales Product initialization (fill stat_sales.Products).
    By default: does nothing

    Parameters:
    Name Type Description
    fp string

    Final path , as computed for Perimeter mapping (Initial or Customized or Remainder)

    Example
    this.initSalesProducts = function(fp)
    {
        //TODO:  
    };

    isExcluded(fp) → {boolean}

    Ask if current page is not allowed to raise a content tag.
    By default: return false (only pages with ! as first character name are excluded)

    Parameters:
    Name Type Description
    fp string

    Final path , as computed for Perimeter mapping (Initial or Customized or Remainder)

    true if current page must not raise a content tag

    boolean
    Example
    // Exclude content tag coming from iframe
    this.isExcluded = function(fp)
    {
        return (window.self !== window.top);
    };

    Allows custom handling of Outbound links identification.
    By default: return stat_link.isExitLink(u, true)

    Parameters:
    Name Type Description
    u string

    Link URL

    true when Outbound link (Exit), false when Inbound link (Navigation), undefined when cannot be determined (Action).

    boolean
    Example
    Super.isExitLink=this.isExitLink;
    this.isExitLink=function(u)
    {
       // Don't consider as exit if subdomains are the same  
       return (Super.isExitLink.call(this, u) && getUrlArray()[1]!==getUrlArray(u)[1]);          
    };

    onVideoEvent(e)

    Video Event handler
    By default: does nothing.

    Parameters:
    Name Type Description
    e object

    Video Event

    Example
    this.onVideoEvent = function(fp)
    {
        //TODO: Custom handler
    };

    raiseClickTag(lname, type, node, eopt) → {boolean}

    Raise the click tag. Can be override to modify the event or prevent it.
    By default: return stat_link.raiseClickTag

    Parameters:
    Name Type Attributes Description
    lname string

    Click tag name.

    type string

    Click tag type ('N', 'S', 'T', 'A', 'IS').

    node object

    The node from which click tag is raised.

    e object <optional>

    Current event.

    true to continue event processing, false otherwise

    boolean
    Example
    Super.raiseClickTag=this.raiseClickTag;
    this.raiseClickTag=function(lname,type,node,e)
    {
        // Prevent bubbled events
        return (!e || node===e.target)? Super.raiseClickTag.call(this,lname,type,node,e) : false;
    };

    setParams(fp)

    Entry point to complete ATI parameters.
    By default: does nothing

    Parameters:
    Name Type Description
    fp string

    Final path , as computed for Perimeter mapping (Initial or Customized or Remainder)

    Example
    this.setParams = function(fp)
    {
        // Following migration to text visitor ID, ensure numeric one is no longer cached in a cookie.
        stat_visitor.resetCookieNumeric(); 
    };

    setParamsGA(ga)

    Entry point to complete GA parameters. Don't use with GA Mirroring.
    By default: does nothing

    Parameters:
    Name Type Description
    ga object

    Google Analytics object

    Example
    this.setParamsGA = function(ga)
    {
        // Allow domains linking 
        if (ga) {ga.push(['_setAllowLinker', true]);}
    };

    setPathName(p)

    Set application name from current path name, for Multiple Levels of Inheritance.
    By default: does nothing.
    Stored name must be returned by CStatApp.getName, so that it can be used by CStatApp.factory

  • Called twice in default Class Customizer model: before CStatApp.getProductionPath and before CStatApp.getPerimeterPath, so that it can be refined for other purposes.
  • Never called by Single Level of Inheritance model (so no need to define it).

    Parameters:
    Name Type Description
    p string

    Initial path (first call) or Final path (second call)

    Example
    this.setPathName=function(p)
    {
        // Use third folder (after /country/language) as application name, "home" by default
        var ap=p.split('/');
        this.name=(ap.length>3 && ap[3])?ap[3]:'home';
    };