Products

 

Foreword

AT Internet’s SDK enables you to tag products for sale that are viewed by your users during usage of your application.

The measurement of viewed products needs an option to be activated. Please contact the support centre for more information.

 

Get off to a good start

Once your tag has been initialised, you can send information of viewed products.

If you want to use variables, be sure to import ATInternet, Tracker and Product classes in your Activity.

 

Tagging

The tracker makes a Products object available. This object exposes the following methods:

  • add : Add a viewed product to the list and returns a Product object.
  • remove : Removes a viewed product in the list.
  • removeAll : Removes all viewed products.
  • sendViews : Send all viewed products.
 

Tagging examples

  1. Tagging a viewed product
    package com.atinternet.atinternetdemo;
    
    import android.app.Activity;
    import android.os.Bundle;
    
    import com.atinternet.tracker.ATInternet;
    import com.atinternet.tracker.Tracker;
    
    public class MainActivity extends Activity {
    
        private Tracker tracker;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            tracker = ATInternet.getInstance().getDefaultTracker();
        }
    
        @Override
        protected void onResume() {
            super.onResume();
            tracker.Products().add("ID[p1]", "ID[category1]", "ID[category2]").sendView();
        }
    }
  2. Tagging several viewed products
    package com.atinternet.atinternetdemo;
    
    import android.app.Activity;
    import android.os.Bundle;
    
    import com.atinternet.tracker.ATInternet;
    import com.atinternet.tracker.Tracker;
    
    public class MainActivity extends Activity {
    
        private Tracker tracker;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            tracker = ATInternet.getInstance().getDefaultTracker();
        }
    
        @Override
        protected void onResume() {
            super.onResume();
            tracker.Products().add("ID[p1]");
            tracker.Products().add("ID[p2]");
            tracker.Products().add("ID[p3]");
            tracker.Products().add("ID[p4]");
            tracker.Products().add("ID[p5]");
            tracker.Products().add("ID[p6]");
            
            tracker.Products().sendViews();
        }
    }
  3. Tagging viewed products with an “add to cart”
    package com.atinternet.atinternetdemo;
    
    import android.app.Activity;
    import android.os.Bundle;
    
    import com.atinternet.tracker.ATInternet;
    import com.atinternet.tracker.Product;
    import com.atinternet.tracker.Tracker;
    
    import java.util.ArrayList;
    
    public class MainActivity extends Activity {
    
        private Tracker tracker;
    
        private ArrayList<Product> products = new ArrayList<>();
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            tracker = ATInternet.getInstance().getDefaultTracker();
        }
    
        @Override
        protected void onResume() {
            super.onResume();
            // Enable cart and set an ID
            tracker.Cart().set("1");
    
            // Declare first product
            Product p1 = tracker.Products().add("1254[MF839FA]", "2[Laptop]", "20[Macbook Pro]");
            p1.setQuantity(1)
                    .setUnitPriceTaxFree(1839)
                    .setUnitPriceTaxIncluded(2299);
    
            products.add(p1);
    
            // Declare second product
            Product p2 = tracker.Products().add("1253[MF885FA]", "1[Desktop]", "10[iMac]");
            p2.setQuantity(1)
                    .setUnitPriceTaxFree(1199)
                    .setUnitPriceTaxIncluded(1499);
    
            products.add(p2);
            
            tracker.Cart().Products().add(p1);
        }
    }
  4. Removal of a product
    @Override
    protected void onResume() {
            super.onResume();
            tracker.Products().remove("1254[MF839FA]");
    }
  5. Removal of all products
    @Override
    protected void onResume() {
            super.onResume();
            tracker.Products().removeAll();
    }
 

Product class

 

Properties

Name Type Default value Description
productId String Empty string Gets or sets the product ID
category1 String null Gets or sets the first product category
category2 String null Gets or sets the second product category
category3 String null Gets or sets the third product category
category4 String null Gets or sets the fourth product category
category5 String null Gets or sets the fifth product category
category6 String null Gets or sets the sixth product category
quantity Int -1 Gets or sets the product quantity
unitPriceTaxIncluded Double -1 Gets or sets the price per unit (including tax)
unitPriceTaxFree Double -1 Gets or sets the price per unit (without tax)
discountTaxIncluded Double -1 Gets or sets the discount amount (including tax)
discountTaxFree Double -1 Gets or sets the discount amount (without tax)
promotionalCode String null Gets or sets the product’s promotional code
 

Was this post helpful?

Last update: 11/06/2018