Custom Object

 

Foreword

The SDK allows the addition of all sorts of information to the stc variable via dictionaries or JSON feeds. Custom objects can be added to any type of tagging, and can then be treated via the Data Manager tool.

 

Get off to a good start

Once your tag is initialised, you can add your custom objects to your hits.

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

 

Tagging

To add a custom object to your hits, the tracker exposes a CustomObjects object possessing an Add method. This method allows for the addition of a custom object that will be added to the next hit sent.

 

Tagging examples

  1. Tagging a screen with addition of a “simple” custom object
    using System;
    using System.Collections.Generic;
    using Windows.Data.Json;
    using Windows.UI.Xaml;
    using Windows.UI.Xaml.Controls;
    using ATInternet;
    using Windows.UI.Xaml.Navigation;
    
    namespace App1
    {
        public sealed partial class MainPage : Page
        {
            Tracker tracker;
    
            public MainPage()
            {
                this.InitializeComponent();
                tracker = SmartTag.Instance.defaultTracker;
                IDictionary<string, object> customObj = new Dictionary<string, object>();
                customObj.Add("firstname", "John");
                customObj.Add("lastname", "Doe");
                tracker.CustomObjects.Add(customObj);
                tracker.Screens.Add().SendView();
            }
        }
    }

    JSON result in stc variable  :

    {
        "lifecycle": {
            "fl": 0,
            "fld": 20151014,
            "dsfl": 1,
            "flau": 0,
            "dslu": 0,
            "lc": 57,
            "lcsu": 0,
            "ldc": 9,
            "lwc": 57,
            "lmc": 57
        },
        "firstName": "John",
        "age": 26,
        "name": "Doe"
    }
  2. Tagging a screen with addition of a “complex” custom object
    using System;
    using System.Collections.Generic;
    using Windows.Data.Json;
    using Windows.UI.Xaml;
    using Windows.UI.Xaml.Controls;
    using ATInternet;
    using Windows.UI.Xaml.Navigation;
    
    namespace App1
    {
        public sealed partial class MainPage : Page
        {
            Tracker tracker;
    
            public MainPage()
            {
                this.InitializeComponent();
                tracker = SmartTag.Instance.defaultTracker;
                
                IDictionary<string, object> info = new Dictionary<string, object>();
                info.Add("country", "US");
                info.Add("language", "en");
    
                IDictionary<string, object> userObj = new Dictionary<string, object>();
                userObj.Add("user", info);
                tracker.CustomObjects.Add(userObj);
                tracker.Screens.Add().SendView();
            }
        }
    }

    JSON result in stc variable  :

    {
        "lifecycle": {
            "fl": 0,
            "fld": 20151014,
            "dsfl": 1,
            "flau": 0,
            "dslu": 0,
            "lc": 58,
            "lcsu": 0,
            "ldc": 10,
            "lwc": 58,
            "lmc": 58
        },
        "user": {
            "language": "en",
            "currency": "USD",
            "country": "US"
        }
    }
  3. Tagging navigation with the addition of a custom object
    using System;
    using System.Collections.Generic;
    using Windows.Data.Json;
    using Windows.UI.Xaml;
    using Windows.UI.Xaml.Controls;
    using ATInternet;
    using Windows.UI.Xaml.Navigation;
    
    namespace App1
    {
        public sealed partial class MainPage : Page
        {
            Tracker tracker;
    
            public MainPage()
            {
                this.InitializeComponent();
                tracker = SmartTag.Instance.defaultTracker;
                tracker.CustomObjects.Add(new Dictionary<string, object>() {
                    { "user", new Dictionary<string,object>() {
                        {"language", "en" },
                        {"country" , "US" },
                        {"currency", "USD" },
                    }}
                });
                tracker.Gestures.Add().SendNavigation();
            }
        }
    }
  4. Tagging an ad with the addition of a custom object
    using System;
    using System.Collections.Generic;
    using Windows.Data.Json;
    using Windows.UI.Xaml;
    using Windows.UI.Xaml.Controls;
    using ATInternet;
    using Windows.UI.Xaml.Navigation;
    
    namespace App1
    {
        public sealed partial class MainPage : Page
        {
            Tracker tracker;
    
            public MainPage()
            {
                this.InitializeComponent();
                tracker = SmartTag.Instance.defaultTracker;
                tracker.CustomObjects.Add(new Dictionary<string, object>() {
                    { "user", new Dictionary<string,object>() {
                        {"language", "en" },
                        {"country" , "US" },
                        {"currency", "USD" },
                    }}
                });
                tracker.Publishers.Add("ads1").SendImpression();
            }
        }
    }
 

CustomObject class

 

Properties

NameTypeDefault valueDescription
JsonString{}Gets or sets the object in JSON format
 

Was this post helpful?

Last update: 29/10/2015