Screens

 

Get off to a good start

Once your tag is initialised, you can start tagging your screens.

To use SDK class and methods, add ATInternet namespace to your Page

Declare a Tracker-type variable in your Page

using System;
using System.Collections.Generic;
using Windows.Data.Json;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using ATInternet;

namespace App1
{
    public sealed partial class MainPage : Page
    {
        Tracker tracker;

        public MainPage()
        {
            this.InitializeComponent();
            tracker = SmartTag.Instance.defaultTracker;
        }
    }
}
 

Tagging

To tag a screen, the tracker exposes a Screens object.

Two solutions are available to tag a screen:

  • Define one or several tagging and send the hit(s) at the desired moment
  • Send screen tagging directly

To do this, the Screens object of the Tracker class offers an Add method.
This method enables the addition of screen tagging which can be sent at the desired moment (e.g. onCreate, onResume…).

The Add method sends back a Screen-type object. To send the defined information, you must manually call the SendView method of your Screen object, or call the Tracker’s Dispatch method.

The method can take several different parameters:

  1. A character string to give a specific name
  2. A Context to retrieve the class name where tagging is done
 

Tagging examples

  1. Tagging a screen:
    protected override void OnNavigatedFrom (NavigationEventArgs e)
    {
         tracker.Screens.Add("Home").sendView();
    }
  2. Tagging a screen with a level 2:
    protected override void OnNavigatedFrom (NavigationEventArgs e)
    {
         Screen screen = tracker.Screens.Add("home");
         screen.Level2 = 1;
         screen.SendView();
    }
  3. Tagging a screen with chapters:
    protected override void OnNavigatedFrom (NavigationEventArgs e)
    {
         tracker.Screens.Add("Today News", "Home", "News").SendView();
    }
  4. Screen tagging with addition of a custom object: In this example, the name of the screen is not entered because it is possible to put the name in the stc parameter in order to use it with DataManager.
    protected override void OnNavigatedFrom (NavigationEventArgs e)
    {
            JsonObject kv = new JsonObject();
            kv.Add("page", JsonValue.CreateStringValue("home"));
            tracker.CustomObjects.Add(kv.Stringify());
            tracker.Screens.Add().SendView();
    }
    
  5. Tagging a screen with use of dispatcher:
    protected override void OnNavigatedFrom (NavigationEventArgs e)
    {
            tracker.CustomVars.Add(2, "customVarScreenValue", CustomVarType.Screen);
            tracker.Screens.Add("home");
            tracker.Dispatch();
    }
    
 

Screen class

 

Properties

NameTypeDefault valueDescription
NameStringEmpty stringGets or sets the screen name
Chapter1StringnullGets or sets the first chapter
Chapter2StringnullGets or sets the second chapter
Chapter3StringnullGets or sets the third chapter
ActionEnumAction.ViewGets or sets the action type
Level2Int-1Gets or sets the level 2 ID
IsBasketScreenBoolfalseIndicates that the screen displays the content of a cart (in the case where the SalesTracker option is used)
 

Méthodes

NameReturn typeDescription
SendViewvoidSends the screen hit
 

Was this post helpful?

Last update: 02/11/2015