Code Monkey home page Code Monkey logo

unity3d-google-analytics's Introduction

unity3d-google-analytics

Track players and events using Google Analytics

Setup

  • Add GoogleAnalytics.cs to your master object
  • Add your property id provided by google (example: UA-XXX-X)
  • Add your default url (example: MySite.com)

Checkout the WIKI for an example on how to create a Google Analytics profile.

Track Level

GALevel level = new GALevel();
// Add the level to the save queue
GoogleAnalytics.instance.Add(level);
// Upload ALL the items in the save queue to Google
GoogleAnalytics.instance.Dispatch();

Track Event

GAEvent myEvent = new GAEvent("MyCategory", "MyAction");
GoogleAnalytics.instance.Add(myEvent);
GoogleAnalytics.instance.Dispatch();

// You can also add a label
GAEvent myEventWithLabel = new GAEvent("MyCategory", "MyAction", "MyLabel");
GoogleAnalytics.instance.Add(myEventWithLabel);
GoogleAnalytics.instance.Dispatch();

// You can also add a value too
GAEvent myEventWithLabelAndValue = new GAEvent("MyCategory", "MyAction", "MyLabel", 5);
GoogleAnalytics.instance.Add(myEventWithLabelAndValue);
GoogleAnalytics.instance.Dispatch();

Track User Timing

GAUserTimer myTimer = new GAUserTimer("MyTimerCategory", "MyTimerVariable");
myTimer.Start();
// Do a bunch of stuff...
myTimer.Stop();
GoogleAnalytics.instance.Add(myTimer);
GoogleAnalytics.instance.Dispatch();

Track ECommerce

// The price is a decimal type!  Don't forget to add the "m" after the numbers.
GAPurchaseItem purchasedItem = new GAPurchaseItem("MySku or ProductId", "MyProductName", 7.99m);
// Add the item to the queue
GoogleAnalytics.instance.Add(purchasedItem);
// Upload the queue
GoogleAnalytics.instance.Dispatch();

TODO

  • Set Custom Variables 8(data)9(data)11(data)

unity3d-google-analytics's People

Contributors

jaredmessenger avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.