Principle

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

Tagging a page:

JavaScript

1

2

3

4

5

6

7

vartag=newATInternet.Tracker.Tag();

tag.page.set({

name:'pageName'

});

tag.dispatch();

Tagging a page with a level 2:

JavaScript

1

2

3

4

5

6

7

8

vartag=newATInternet.Tracker.Tag();

tag.page.set({

name:'pageName',

level2:'123'

});

tag.dispatch();

Tagging a page with chapters:

JavaScript

1

2

3

4

5

6

7

8

9

10

vartag=newATInternet.Tracker.Tag();

tag.page.set({

name:'pageName',

chapter1:'chap1',

chapter2:'chap2',

chapter3:'chap3'

});

tag.dispatch();

Tagging a page with the addition of a custom object:

JavaScript

1

2

3

4

5

6

7

8

9

10

11

vartag=newATInternet.Tracker.Tag();

tag.page.set({

name:'pageName',

customObject:{

param1:'val1',

param2:'val2'

}

});

tag.dispatch();

Tagging an empty chapter :

JavaScript

1

2

3

4

5

6

7

8

9

vartag=newATInternet.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()”.

Complete tagging:

JavaScript

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

vartag=newATInternet.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: