• There are multiple things that can be tracked via GA, such as: Pageviews, Events, Ecommerce Trarnsactions and Custom Variables
  • We will be using Event tracking and will add some Custom variables to the Events
  • Event contains four fields that can be provided
  1. Category
  2. Action
  3. Label
  4. Value

We will use the above fields slightly differently than intended, below is explanation for each field:

1. Category

In this field we will put the action that the user has taken, such as Search, Browse, Share, Vote etc. Some of the possible actions are:
“Browse”,”Search”,”Share”,”Click”,”Vote”, “Call”, “Map”, “Directions”,”Website”

2. Action

In this filed we will put the vertical, that the user is performing the action with in, some of the possible verticals are: “Local”,”Restaurants”,”Movies”,”Weather”,”Sports”,”Products”

3. Label

The value for label field is not mandatory and it depends on the Action the user has taken, For “Search” set the value to query the user entered.

For other actions, the value TBD

4. Value

The Value field is not currently used, so the value can be set to 0.


Custom Fields

Custom variables can be added to the Events prior to calling the trackEvent function via the SDK

there are are two custom variable required right now to be added to each event, for both events set the scope of the variable to 3

1. appId

  Set the index for this to 1, name should be set to appId, the value should be the "name of your app" which is assigned to you. the scope again should be set to 3(page-level).

2. appVersion

  Set the index for this to 2, name should be set to appVersion, the value should be the name of version of your app. the scope again should be set to 3(page-level).

Sample Code, Android (Generates Random Events):

  GoogleAnalyticsTracker tracker = GoogleAnalyticsTracker.getInstance();
  // Start the tracker in manual dispatch mode...
  tracker.startNewSession("UA-32139049-1", this);
  private void creatRandomEvents(){
  	  String [] appIds = new String[]{"app1","app2","app3"};
  	  String [] appVersions = new String[]{"1.0","1.03","1.1"};

  	  String [] categories = new String[]{"Browse","Search","Share","Click","Vote", "Call", "Map", "Directions","Website"};
  	  String [] verticals = new String[]{"Local","Movies","Weather","Sports","Products"};

  	  String [] localQueries = new String[]{"Pizza","Sushi","Ping Pong","Pharmacy","Chinese Restaurant","Indian Restaurant","Golf","Bike Shop","Hockey Shop"};

  	  String [] movieNames = new String[]{"17 Girls (17 Filles)","21 Jump Street","360 Peter","47 Ronin","4:44 Last Day on Earth","7500","A Bottle in the Gaza Sea (Une bouteille a la mer)","A Cat in Paris (Une vie de chat)","A Dangerous Method","A Drummer's Dream","A Gentle Woman (Une femme douce)","A Good Day to Die Hard","A Happy Event (Un heureux evenement)","A Monster in Paris (Un monstre a Paris)","A Monster in Paris 3D (Un monstre a Paris 3D)","A Separation (Jodaeiye Nader az Simin)","A Thousand Words","ATM","Abraham Lincoln: Vampire Hunter 3D","Abraham Lincoln: Vampire Hunter","Act of Valor","After Earth","Albert Nobbs","Alex Cross","All Our Desires (Toutes nos envies)","Alvin and the Chipmunks: Chipwrecked","American Reunion","An Evening With Don Hertzfeldt","Andrew Lloyd Webber's Love Never Dies","Angele and Tony (Angele et Tony)","Aravaan","Argo","Arjun","Attenberg","Back to the Sea 3D","Back to the Sea","Bad Ass","Barfii","Baseball, Dennis & the French","Battle Royale (Batoru rowaiaru)","Battle of the Year: The Dream Team","Battlefield America","Battleship","Be Here to Love Me: A Film About Townes Van Zandt","Beasts of the Southern Wild","Beautiful Creatures","Beautiful Diaries","Being Flynn","Bel Ami","Bending All the Rules","Bending the Rules","Berliner Philharmoniker III 2011 2012","Bernie","Bestiaire (1970)","Big Miracle","Black Butterflies","Blow-Up","Blue Like Jazz","Bollywood","Bolshoi Ballet: Le Corsaire LIVE","Bolshoi Ballet: Raymonda LIVE","Book Club with Michael Smerconish featuring Chris Matthews","Brake","Brave in Disney Digital 3D","Brave","Broken City","Bullet to the Head","Bully","Burma Soldier","Butter","Cafe de flore","Can U Feel it - The UMF Experience","Captain Phillips","Carnage","Casa de mi Padre","Case Depart","Catching Fire","Chernobyl Diaries","Chico & Rita","Chimpanzee","Chronicle","Circus Columbia (Cirkus Columbia)","Cirque du Soleil: Worlds Away","Cogan's Trade","Color of the Ocean (Die Farbe des Ozeans)","Comic-Con: Episode IV - A Fan's Hope","Comme un chef","Contraband","Coriolanus","Damsels in Distress","Dark Shadows","Dark Shadows: An IMAX 3D Experience","Dark Shadows: An IMAX Experience","Darling Companion","Delicacy (La delicatesse)","Derapages","Despicable Me 2","Detachment","Detention","Detroit Video Music Award Nominations","Diana Vreeland: The Eye Has to Travel","Diary of a Country Priest (1951)","Diary of a Wimpy Kid: Dog Days","Dirty Dancing","Django Unchained","Donny's Boy","Dorothy of Oz","Dr. Seuss' The Lorax 3D","Dr. Seuss' The Lorax","Dr. Seuss' The Lorax: An IMAX 3D Experience","Dredd 3D","Dredd","Early One Morning (De bon matin)","Easy Money (Snabba Cash)","Ek Main Aur Ekk Tu","Elysium","Ender's Game","Escape from Planet Earth 3D","Escape from Planet Earth","Evil Dead","Exit Strategy","Extremely Loud & Incredibly Close","Face/Off","Falling Away","Family Portrait in Black and White","Finding Nemo 3D","Fly Away Home","Footnote (Hearat Shulayim)","For Greater Glory","Frankenweenie in Disney Digital 3D","Frankenweenie","Free Men (Les hommes libres)","Friends With Kids","Frozen","Fun Size","G.I. Joe 2: Retaliation","Gangster Squad","Ghost Rider 3D: Spirit of Vengeance","Ghost Rider: Spirit of Vengeance","Girl in Progress","God Bless America","God's Country","Gone","Good For Nothing","Goodbye First Love (Un amour de jeunesse)","Goon","Granito","Grateful Dead Meet Up 2012","Gravity 3D","Gravity Peter","Gravity: An IMAX Experience","Great Hope Springs","Grown Ups 2","Guilty (Presume coupable)","Halloween 3D","Hansel and Gretel: Witch Hunters 3D","Hansel and Gretel: Witch Hunters","Happy Feet Two","Haywire","Headhunters (Hodejegerne)","Here Comes the Boom","Heroine","High School","Hit So Hard","Hotel Transylvania 3D","House at the End of the Street","How to Die in Oregon","Hugo 3D","Hugo","Hunter Killer","Hyde Park on Hudson","Hysteria","I Am Bruce Lee","I Kissed a Vampire","I'm Yours","I, Frankenstein","Ice Age: Continental Drift 3D","Ice Age: Continental Drift","In Darkness","In Studio: 32nd Annual Genie Award Nominees","In the Land of Blood and Honey","Into the Abyss","Intruders","Iron Man 3","Jack Reacher: One Shot","Jack the Giant Killer 3D","Jack the Giant Killer","Jack the Giant Killer: An IMAX 3D Experience","Jane Goodall's Wild Chimpanzees","Jeff, Who Lives at Home","Jiro Dreams of Sushi","Jo's Boy (Le fils à Jo)","Jodi Breakers","Joe Satriani: Satchurated in 3D","Joe Satriani: Satchurated","John Carter in Disney Digital 3D","John Carter","John Carter: An IMAX 3D Experience","John Carter: The IMAX Experience","Joker 3D","Joseph and the Amazing Technicolor Dreamcoat","Journey 2: The Mysterious Island 3D","Journey 2: The Mysterious Island","Journey 2: The Mysterious Island: An IMAX 3D Experience","Journey 2: The Mysterious Island: An IMAX Experience","Joyful Noise","Juan of the Dead (Juan de los muertos)","Jumanji","Kahaani","Ken Davis Fully Alive","Keyhole","Kill List","King of Devil's Island (Kongen av Bastoy)","King of the Elves in Disney Digital 3-D","Knock on Any Door (1949)","Kumki","L!fe Happens","L'Empire Bo$$e","LA Phil Live: Gustavo Dudamel and Herbie Hancock Celebrate Gershwin","La Boheme from Gran Teatre del Liceu (Live)","La cle des champs","La peur de l'eau","Lancelot of the Lake (Lancelot Du Lac)","Last Call At The Oasis","Leafmen in 3D","Leafmen","Les Miserables","Let the Bullets Fly (Rang zidan fei)","Letters to Elena (Cartas a Elena)","Life of Pi 3D","Life of Pi","Little Terrors Volume 8: Hidden Worlds","Live Comedy","Lockout","London Paris New York","Lone Ranger","Looper","Losing Control","Love","Lovely Molly","MONUMENTAL: In Search of America's National Treasure","Madagascar 3: Europe's Most Wanted 3D","Madagascar 3: Europe's Most Wanted","Magic Mike","Man of Steel","Man on a Ledge","Marvel Untitled 1","Marvel Untitled 2","Marvel's The Avengers 3D","Marvel's The Avengers","Marvel's The Avengers: An IMAX 3D Experience","Matthew Bourne's Swan Lake in 3D","Men In Black 3: An IMAX 3D Experience","Men in Black 3 in 3D","Men in Black 3","Mesnak","Midnight in Paris","Midwest Ballet Theatre: Alice in Wonderland","Mirror Mirror","Miss Representation","Mission: Impossible - Ghost Protocol","Mission: Impossible - Ghost Protocol: The IMAX Experience","Mon pere est femme de menage","Monsieur Lazhar","Monsters University","Monsters, Inc. 3D","Moonrise Kingdom","Mort subite d'un homme-theatre","Mother's Day","Movie 43","Muppozhudhum Un Karpanaigal","Musical Chairs","My Way (Mai wei)","My Week with Marilyn","Nadia's Journey (Le Voyage de Nadia)","National Theatre Live: She Stoops to Conquer ENCORE","National Theatre Live: She Stoops to Conquer","National Theatre Live: The Comedy of Errors ENCORE","Natural Selection","Neighborhood Watch","Neil Young Journeys","Nero Fiddled","Newlyweds","Norwegian Wood (Noruwei no mori)","Now You See Me","October Baby","Of Men and Mavericks","Omerta","Once Upon a Time in Anatolia (Bir Zamanlar Anadolu'da)","One Life","One Shot","One for the Money","Ouija","Outrun","Over My Dead Body","Oz: The Great and Powerful","Pacific Rim in 3D","Pacific Rim","ParaNorman 3D","ParaNorman","Paranormal Activity 4","Parental Guidance","Pariah","Parker","Payback: Debt and the Shadow Side of Wealth","Percy Jackson & the Olympians: The Sea of Monsters","Perfect Sense","Phineas and Ferb: Across the second dimension","Pina 3D","Pina","Pink Ribbons, Inc.","Pixels","Playback","Playing the Field","Polisse (Poliss)","Pray for Japan","Premium Rush","Pressure","Project X","Prometheus 3D","Prometheus","Puss in Boots","Quais-blues","Quill: The Life of a Guide Dog","R.I.P.D.","Rampart","Rascal Flatts: Changed","Re:Generation Music Project","Reboot Ralph 3D","Red 2","Red Dawn","Red Tails","Reel Talk","Resident Evil: Retribution 3D","Resident Evil: Retribution","Return","Reuniting the Rubins","Rise of the Guardians","Roadie","Robopocalypse","Rock of Ages","Rocky Mountain Express: An IMAX Experience","Romeo Eleven (Romeo Onze)","Rowdy Rathore","Safe Haven: The Underground Railroad During the Vietnam War","Safe House","Safe","Safety Not Guaranteed","Salmon Fishing in the Yemen","Savages","Scary Movie 5","Searching for Sugar Man","Seeking Justice","Seeking a Friend for the End of the World","Servitude","Seventh Son","Shame","Sherlock Holmes: A Game of Shadows","Sholem Aleichem: Laughing in the Darkness","Silent House","Singularity","Sinister","Skyfall","Skyfall: The IMAX Experience","Sleeping Beauty","Smurfs 2","Snow White and the Huntsman","Snow","Sound of My Voice","Sound of Noise","Sparkle","Star Trek 2 3D","Star Trek 2","Star Wars: Episode I - The Phantom Menace 3D","Star Wars: Episode I - The Phantom Menace","Starry, Starry Night (Xing kong)","Step Up 4","Stretch Armstrong 3D","Stretch Armstrong","Surviving Progress","TCM Presents Casablanca 70th Anniversary Event","Take This Waltz","Taken 2","Tales of the Night (Les contes de la nuit)","Tales of the Night 3D (Les contes de la nuit 3D)","Ted","Ten Year","Tere Naal Love Ho Gaya","That's My Boy","The ABCs of Death","The Adventures of Tintin","The Amazing Spider-Man 2 in 3D","The Amazing Spider-Man 2","The Amazing Spider-Man 3D","The Amazing Spider-Man in IMAX 3D","The Amazing Spider-Man","The Amazing Spider-Man: The IMAX Experience","The Apparition","The Artist","The Assault (L'assaut)","The Awakening","The Ballad of Genesis and Lady Jaye","The Baytown Disco","The Beat Hotel","The Best Exotic Marigold Hotel","The Bourne Legacy","The Cabin in the Woods 3D","The Cabin in the Woods","The Campaign","The Cold Light of Day","The Croods","The Dark Knight Rises","The Dark Knight Rises: The IMAX Experience","The Decoy Bride","The Deep Blue Sea","The Descendants","The Devil Inside","The Devil Probably (Le diable probablement)","The Dictator","The Divide","The Expendables 2","The FP","The Fast & Furious 6","The Five-Year Engagement","The Flowers of War (Jin ling shi san chai)","The Girl With the Dragon Tattoo","The Gold of Others (L'or des autres)","The Good Doctor","The Great Gatsby in 3D","The Great Gatsby","The Grey","The Guardians","The Guilt Trip (My Mother's Curse)","The Hobbit: An Unexpected Journey in 3D","The Hobbit: An Unexpected Journey in IMAX 3D","The Hobbit: An Unexpected Journey","The Hobbit: There and Back Again in 3D","The Hobbit: There and Back Again","The Host","The Hunger Games","The Hunger Games: The IMAX Experience","The Hunter","The Innkeepers","The Intouchables (Intouchable)","The Iron Lady","The Island President","The Kid With a Bike (Le Gamin au Velo)","The Ladies of the Bois de Boulogne (Les dames du Bois de Boulogne)","The Lady","The Last Movie","The Last Stand","The Little Mermaid 3D","The Lucky One","The Marriage Counselor","The Metropolitan Opera: Ernani Encore","The Metropolitan Opera: La Traviata (Encore)","The Metropolitan Opera: La Traviata","The Metropolitan Opera: Manon (Encore)","The Metropolitan Opera: Manon","The Metropolitan Opera: The Enchanted Island Encore","The Moth Diaries","The Muppets","The Niagara Falls Movie: Legends and Daredevils in IMAX","The Odd Life of Timothy Green","The Odds","The Oogieloves in the Big Balloon Adventure","The Pirates! Band of Misfits 3D","The Pirates! Band of Misfits","The Possession","The Price of Sex","The Prodigies (La Nuit des enfants Rois)","The Prodigies 3D (La Nuit des enfants Rois 3D)","The Raid: Redemption (Serbuan maut)","The Raven","The Rocky Horror Picture Show","The Salt of Life (Gianni e le donne)","The Secret World of Arrietty (Kari-gurashi no Arietti)","The Silent House (La casa muda)","The Silver Linings Playbook","The Source (La source des femmes)","The Texas Chainsaw Massacre 3D","The Three Stooges","The Trial of Joan of Arc (Proces de Jeanne d'Arc) (1962)","The Trouble with Bliss","The Twilight Saga: Breaking Dawn - Part 2","The Understudy","The Vow","The Wedding","The Well Digger's Daughter (La Fille du puisatier)","The Wettest County","The Wolverine","The Woman in Black","The Woman in the Fifth (La femme du Vème)","Think Like a Man","Thirty: Two Shorts Films About Glen Gould","This Binary Universe","This Means War","This is My Land: Hebron","Thor 2","Tim and Eric's Billion Dollar Movie","Tinker Tailor Soldier Spy","Titanic 3D Fan Sneak Preview","Titanic 3D","Titanic: The IMAX 3D Experience","To The Arctic IMAX 3D","To The Arctic IMAX","Tonight You're Mine","Tornado Alley","Total Recall","Touch","Touchback","Transformers 4","Trente tableaux","Trishna","Trouble with the Curve","Turbo","Turn Me On, Dammit (Fa meg pa, for faen)","Tyler Perry's Good Deeds","Undefeated","Under the Sea","Underworld: Awakening 3D","Underworld: Awakening","Underworld: Awakening: An IMAX 3D Experience","Underworld: Awakening: An IMAX Experience","Unforgivable (Impardonnables)","United States of Africa -- Les États-Unis d'Afrique","Untitled 3D DWA Animation","Untitled David Chase Project","Untitled Farrell/Wessler Comedy","Untitled Henry Selick Film in 3D","Untitled Judd Apatow Project","Untitled Kathryn Bigelow Project","Untitled Tom Cruise","V/H/S","W.E.","Walking With Dinosaurs 3D","Wanderlust","War Horse","Warm Bodies","Warriors of the Rainbow: Seeqid Bale","We Bought a Zoo","We Have a Pope (Habemus Papam)","We Need to Talk About Kevin","We the Party","We the Peeples","What to Expect When You're Expecting","Where Do We Go Now? (Et maintenant, on va ou?)","White Button (Bijelo Dugme)","Woman Thou Art Loosed: On the 7th Day","Won't Back Down","World War Z","Wrath of the Titans 3D","Wrath of the Titans","Wrath of the Titans: An IMAX 3D Experience","Wrath of the Titans: An IMAX Experience","Wreck-It Ralph","Zombie Dawn"};

  	  for(int i =0; i<100;i++){

  		  String appId= appIds[(int)(Math.random()*appIds.length)];
  		  String appVersion= appVersions[(int)(Math.random()*appVersions.length)];

  		  String vertical = verticals[(int)(Math.random()*verticals.length)];
  		  String query="";

  			  query = localQueries[(int)(Math.random()*localQueries.length)]; 
  		  }else   if(vertical.equals(verticals[1])){
  			  query = movieNames[(int)(Math.random()*movieNames.length)];

  		  String category = categories[(int)(Math.random()*categories.length)];

  		  tracker.setCustomVar(1, "appId", appId,3);
  		  tracker.setCustomVar(2, "appVersion", appVersion,3);
              category,  // Category
              vertical,  // Action
              query, // Label
              0);       // Value