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

NameTypeDefault valueDescription
productIdStringEmpty stringGets or sets the product ID
category1StringnullGets or sets the first product category
category2StringnullGets or sets the second product category
category3StringnullGets or sets the third product category
category4StringnullGets or sets the fourth product category
category5StringnullGets or sets the fifth product category
category6StringnullGets or sets the sixth product category
quantityInt-1Gets or sets the product quantity
unitPriceTaxIncludedDouble-1Gets or sets the price per unit (including tax)
unitPriceTaxFreeDouble-1Gets or sets the price per unit (without tax)
discountTaxIncludedDouble-1Gets or sets the discount amount (including tax)
discountTaxFreeDouble-1Gets or sets the discount amount (without tax)
promotionalCodeStringnullGets or sets the product’s promotional code
 

Was this post helpful?

Last update: 11/06/2018