Sample Code - Industry Based

Based on your domain - e-commerce, lead generation, travel, publisher, etc, the events and the properties basis which you would segment your subscribers could be different. Here are few templates that you can refer to.

Publishers

Sample Code for Capturing User-Specific data on a Lead Generation Form

<script> window._izq.push(["userProfile",{"add":{
"Gender":"Male"   //Key - Value can be customized to suit your needs
}}]);
</script>
HashMap<String, Object> data = new HashMap<>();

data.put("Gender","Male");
//Key - Value can be customized to suit your needs

iZooto.addUserProperty(data);
let data = ["Gender": "Male"] as [String : Any]
//Key - Value can be customized to suit your needs

iZooto.addUserProperties( data: data)

Sample Code to track the pages/category viewed by a user

<script> window._izq.push(["userProfile",{"add":{
"Page_Viewed":"Sports"   //Key - Value can be customized to suit your needs
}}]);
</script>
HashMap<String, Object> data = new HashMap<>();

data.put("Screen_Viewed","Sports");
//Key - Value can be customized to suit your needs

iZooto.addUserProperty(data);
let data = ["Screen_Viewed": "Sports"] as [String : Any]
//Key - Value can be customized to suit your needs

iZooto.addUserProperties( data: data)

E-Commerce

Sample Code for Tracking Views on Collection/Category Pages

<script> window._izq.push(["event","collection_viewed",{ 
"collection_title":"Shirts", 
"collection_link":"https://yourwebsite.com/collections/shirts", 
"collection_image":"https://yourwebsite.com/media/coll/image/000121.jpg"  /*optional*/
 }]); </script>
HashMap<String, Object> data = new HashMap<>();

data.put("collection_title","Shirts");
data.put("collection_image","https://yourwebsite.com/media/coll/image/000121.jpg");
data.put("collection_price",120430);

iZooto.addEvent("collection_viewed",data);
let data = ["collection_title": "Shirts", 
"collection_image": "https://yourwebsite.com/media/coll/image/000121.jpg",
"collection_price":120430] as [String : Any]

iZooto.addEvent(eventName: "collection_viewed",data: data)

Sample Code for Tracking Views on Product Pages

<script> window._izq.push(["event","product_viewed",{ 
"product_title":"Emoji half sleeve teeshirt", 
"product_price":"499", /*optional*/
"product_link":"https://yourwebsite.com/shirts/tees/emoji_half", 
"product_image":"https://yourwebsite.com/media/products/image/000481.jpg" 
 }]); </script>
HashMap<String, Object> data = new HashMap<>();

data.put("product_title","Emoji half sleeve teeshirt");
data.put("product_price",499);
data.put("product_image","https://yourwebsite.com/media/coll/image/000121.jpg");

iZooto.addEvent("product_viewed",data);
let data = ["product_title": "Emoji half sleeve teeshirt", 
"product_price": "499",
"product_image": "https://yourwebsite.com/media/coll/image/000121.jpg"] as [String : Any]

iZooto.addEvent(eventName: "product_viewed",data: data)

Sample Code for Tracking Clicks on the Add to Cart Button

<script> window._izq.push(["event","added_to_cart",{ 
"product_title":"Emoji half sleeve teeshirt", 
"product_price":"499",  /*optional*/
"product_image":"https://yourwebsite.com/media/products/image/000481.jpg", 
}]); </script>
HashMap<String, Object> data = new HashMap<>();

data.put("product_title","Emoji half sleeve teeshirt");
data.put("product_price",499);
data.put("product_image","https://yourwebsite.com/media/coll/image/000121.jpg");

iZooto.addEvent("added_to_cart",data);
let data = ["product_title": "Emoji half sleeve teeshirt", 
"product_price": "499",
"product_image": "https://yourwebsite.com/media/coll/image/000121.jpg"] as [String : Any]

iZooto.addEvent(eventName: "added_to_cart",data: data)

Sample Code for Tracking Successful Purchases

<script> window._izq.push(["event","order_placed",{ 
"cart_value":"2000", 
"product_count":"3" 
}]); </script>
HashMap<String, Object> data = new HashMap<>();

data.put("cart_value",2000);
data.put("product_count",3);

iZooto.addEvent("order_placed",data);
let data = ["cart_value": 2000, 
"product_count": 3] as [String : Any]

iZooto.addEvent(eventName: "added_to_cart",data: data)

Hospitality

Sample Code for Tracking Clicks on the Book Now Button for Hotels

<script> window._izq.push(["event","hbooking",{
                   "hotelname":"my hotel",
                   "checkin":"2018-04-27",  
                   "checkout":"2019-02-13",
                   "landingURL":"https://www.landing.com",
                   "bookingURL":"https://www.booking.com"
           }]); </script>
HashMap<String, Object> data = new HashMap<>();

data.put("hotelname","My Hotel");
data.put("checkin","2018-04-27");
data.put("checkout","2019-02-13");
data.put("Screen_ID",123);

iZooto.addEvent("hbooking",data);
let data = ["hotelname": "My Hotel", 
"checkin": "2018-04-27",
"checkout": "2019-02-13",
"Screen_ID": 1233] as [String : Any]

iZooto.addEvent(eventName: "hbooking",data: data)

Sample Code for Tracking Successful Hotel Bookings

<script> window._izq.push(["event","hotelticketed",{  
                   "hotelname":"my hotel",
                   "checkin":"2018-04-27",  
                   "checkout":"2019-02-13"
           }]); </script>
HashMap<String, Object> data = new HashMap<>();

data.put("hotelname","My Hotel");
data.put("checkin","2018-04-27");
data.put("checkout","2019-02-13");

iZooto.addEvent("hotelticketed",data);
let data = ["hotelname": "My Hotel", 
"checkin": "2018-04-27",
"checkout": "2019-02-13"] as [String : Any]

iZooto.addEvent(eventName: "hotelticketed",data: data)

Aviation

Sample Code for Tracking Clicks on the Book Now Button for Flights

<script> window._izq.push(["event","book-now",{
                   "flying-from":"delhi",
                   "flying-to":"goa",
                   "departure_date":"2019-04-13",
                   "landingURL":"https://www.landing.com",
                   "bookingURL":"https://www.booking.com"
                 }]); </script>
HashMap<String, Object> data = new HashMap<>();

data.put("flying-from","Delhi");
data.put("flying-to","Goa");
data.put("departure_date","2019-04-13");
data.put("screen_id",123);

iZooto.addEvent("book-now",data);
let data = ["flying-from": "Delhi", 
"flying-to": "Goa",
"departure_date": "2019-04-13",
"screen_id": 123] as [String : Any]

iZooto.addEvent(eventName: "book-now",data: data)

Sample Code for Tracking Successful Flight Bookings

<script> window._izq.push(["event","transact",{
                   "flying-from":"delhi",
                   "flying-to":"goa",
                   "departure_date":"2019-04-13"
                 }]); </script>
HashMap<String, Object> data = new HashMap<>();

data.put("flying-from","Delhi");
data.put("flying-to","Goa");
data.put("departure_date","2019-04-13");

iZooto.addEvent("transact",data);
let data = ["flying-from": "Delhi", 
"flying-to": "Goa",
"departure_date": "2019-04-13"] as [String : Any]

iZooto.addEvent(eventName: "transact",data: data)

Real Estate

Sample Code for Tracking Views on Project/Landing Pages

<script> window._izq.push(["event","page_visited",{
                          "Project Name":"The Park"
                          }]); </script>
HashMap<String, Object> data = new HashMap<>();

data.put("Project Name","The Park");

iZooto.addEvent("page_visited",data);
let data = ["Project Name": "The Park"] as [String : Any]

iZooto.addEvent("page_visited",data)

Sample Code for Tracking Clicks on the Submit Button/Thank You Page

<script> window._izq.push(["event","form_submitted",{
                           "Project name":" The Park "
                           }]); </script>
HashMap<String, Object> data = new HashMap<>();

data.put("Project Name","The Park");

iZooto.addEvent("form_submitted",data);
let data = ["Project Name": "The Park"] as [String : Any]

iZooto.addEvent("form_submitted",data)

Sample Code for Tracking Content Categories

Verification (Using GTM)

Open your website linked with GTM in Preview mode.

  • Imitate the user activity you want to verify.
  • If the implementation is done correctly, you will be able to see the events fired in the GTM preview panel.

Follow this link to know in detail.


What’s Next
Did this page help you?