Pages

 

Foreword

Before starting implementation of the Page plugin, please make sure you have initialised the AT Internet JavaScript Tracker and selected the plugin from within the Tag Composer interface.

 

Principle

The JavaScript plugin Page the measurement of pages on your site.

 

Tagging

The Tracker has a “.set()” method enabling the definition of page tag values. This method takes an object as a parameter whose properties are as follows:

  • name: Page name/label.
  • chapter1: First chapter level.
  • chapter2: Second chapter level.
  • chapter3: Third chapter level.
  • level2: Level 2.
  • customObject: Custom parameters.

If the “name” parameter is empty (name: '') and “chapter1”, “chapter2” and “chapter3” parameters are not defined, the page URL will be used as the page name in your reports.
If the parameters “chapter1”, “chapter2” or “chapter3” are empty, they will be empty as well in the analysis*.

* Since version 5.5.0, a new option (ignoreEmptyChapterValue) allows you to choose if empty chapters must be taken into account (false) or not (true).
>= 5.5.0

Sending page hits is done in this case via the “tag.dispatch()” method.

 

Tagging examples

  1. Tagging a page:
    var tag = new ATInternet.Tracker.Tag();
    tag.page.set({
        name:'pageName'
    });
    tag.dispatch();
  2. Tagging a page with a level 2:
    var tag = new ATInternet.Tracker.Tag();
    tag.page.set({
        name:'pageName',
        level2:'123'
    });
    tag.dispatch();
  3. Tagging a page with chapters:
    var tag = new ATInternet.Tracker.Tag();
    tag.page.set({
        name:'pageName',
        chapter1:'chap1',
        chapter2:'chap2',
        chapter3:'chap3'
    });
    tag.dispatch();
  4. Tagging a page with the addition of a custom object:
    var tag = new ATInternet.Tracker.Tag();
    tag.page.set({
        name:'pageName',
        customObject: {
            param1: 'val1',
            param2: 'val2'
        }
    });
    tag.dispatch();
  5. Tagging an empty chapter :
    var tag = new ATInternet.Tracker.Tag();
    tag.page.set({
        name:'pageName',
        chapter1:'chapter1',
        chapter2:''
    });
    tag.dispatch();

    This will give in the hit: “chapter1::::pageName”, and will create an empty second level chapter in your analysis.

The Tracker also has a “page.send()” method that’s useful for sending hits from time to time, outside of page loads. This method can be called on an action or on an event of your choice.

Additional optional parameters are then available :

  • elem : Tagged DOM element.
  • event : JavaScript event (prevent event propagation) – since v5.7.0.
  • callback : Function to execute – since v5.7.0.

Data in a page context defined during a call to the “page.set()” method are ignored by the method “page.send()”.

  1. Complete tagging:
var tag = new ATInternet.Tracker.Tag();
tag.page.send({
    name:'pageName',
    chapter1:'chap1',
    chapter2:'chap2',
    chapter3:'chap3',
    level2:'123',
    customObject: {
        param1: 'val1',
        param2: 'val2'
    },
    event: anEvent,
    callback: function(){}
});

In this case, there is no use in calling the method “tag.dispatch()”.

 

Tagging a page on a click

In order to tag a page on a click, you can use the “page.send()” method:

<a href="/mypage.html" onclick="return tag.page.send({elem:this, name:'Page', chapter1: 'mychapter', level2: '2'})">Link</a>
 

Authorised characters

The page name that passes through our server via http protocol (web standard) is subject to a few rules, allowing us to achieve a significant level of compatibility with browsers.

The rules are:

  • No accented characters,
  • No spaces (spaces should be replaced by underscores, “_”),
  • No characters other than numbers and letters (no commas, ‘+’, quotation marks or apostrophes).

The authorised characters are:

  • The letters abcdefghijklmnopqrstuvwxyz in big or small letters
  • The numbers 1234567890
  • Periods/dots .
  • Slashes /
  • Dash –
  • Underscores _
  • Tildes ~

You can encode the value if needed

 

The “customObject” parameter

The “customObject” parameter allows for the aggregation of all parameters you wish to measure: please see the entry “Custom object” for more details.

Last update: 17/05/2019