Skip to content

Instantly share code, notes, and snippets.

@jakevsrobots
Created May 16, 2012 22:37
Show Gist options
  • Save jakevsrobots/2714586 to your computer and use it in GitHub Desktop.
Save jakevsrobots/2714586 to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class PlaytimeTracker : MonoBehaviour {
public int heartbeatCount = 0;
void Awake() {
DontDestroyOnLoad(gameObject);
}
void Start() {
StartCoroutine(PlayTimeHeartbeat());
}
IEnumerator PlayTimeHeartbeat() {
while(true) {
GoogleAnalytics.TrackEventWithValue("play_duration_heartbeat_seconds", "", heartbeatCount * 30);
yield return new WaitForSeconds(30);
heartbeatCount++;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment