private void OnDialogueEnded(DialogueItem dialogue, CompositeDisposable subscriptions) { subscriptions.Dispose(); dialogue.ended = true; m_ChatBoxController.HideOptions(); m_ConversationController.StopTyping(); m_DialogueEnded.OnNext(new DialogEndedEvent { item = selectedDialogue.Value, profile = profile.Value, succeeded = dialogue.succeeded }); m_ExitButton.SetActive(true); m_ChatBoxController.gameObject.SetActive(false); AnalyticsEvent.LevelComplete(profile.Value.name, new Dictionary <string, object>() { { "succeeded", dialogue.succeeded } }); var eventHitBuilder1 = new EventHitBuilder() .SetEventCategory("conversation") .SetEventAction("ended") .SetEventLabel(profile.Value.name) .SetEventValue(dialogue.succeeded ? 1L : 0L); GoogleAnalyticsV4.getInstance().LogEvent(eventHitBuilder1); }
private string AddCustomVariables <T>(HitBuilder <T> builder) { if (!trackingCodeSet) { return(""); } String url = ""; foreach (KeyValuePair <int, string> entry in builder.GetCustomDimensions()) { if (entry.Value != null) { url += Fields.CUSTOM_DIMENSION.ToString() + entry.Key + "=" + WWW.EscapeURL(entry.Value.ToString()); } } foreach (KeyValuePair <int, float> entry in builder.GetCustomMetrics()) { if (entry.Value != null) { url += Fields.CUSTOM_METRIC.ToString() + entry.Key + "=" + WWW.EscapeURL(entry.Value.ToString()); } } if (!String.IsNullOrEmpty(url)) { if (GoogleAnalyticsV4.belowThreshold(logLevel, GoogleAnalyticsV4.DebugMode.VERBOSE)) { Debug.Log("Added custom variables to hit."); } } return(url); }
private void InitializeTracker() { if (!initialized) { instance = this; Object.DontDestroyOnLoad(instance); if (string.IsNullOrEmpty(productName)) { productName = Application.productName; } if (string.IsNullOrEmpty(bundleIdentifier)) { bundleIdentifier = Application.identifier; } if (string.IsNullOrEmpty(bundleVersion)) { bundleVersion = Application.version; } UnityEngine.Debug.Log("Initializing Google Analytics 0.2."); androidTracker.SetTrackingCode(androidTrackingCode); androidTracker.SetAppName(productName); androidTracker.SetBundleIdentifier(bundleIdentifier); androidTracker.SetAppVersion(bundleVersion); androidTracker.SetDispatchPeriod(dispatchPeriod); androidTracker.SetSampleFrequency(sampleFrequency); androidTracker.SetLogLevelValue(logLevel); androidTracker.SetAnonymizeIP(anonymizeIP); androidTracker.SetAdIdCollection(enableAdId); androidTracker.SetDryRun(dryRun); androidTracker.InitializeTracker(); initialized = true; SetOnTracker(Fields.DEVELOPER_ID, "GbOCSs"); } }
// private method are done here private void InitQuizz() { // initialization loop startingCategory = GameData.GAME_CATEGORY; _questionCounter = 1; _loadedClips = new List <AudioClip>(); _questionTitles = new List <string>(); _questionImages = new List <Sprite>(); _yesCounter = 0; audioPlayer.ResetQuizz(); FillAudio(startingCategory); // Set the Prompt UI promptUI.SetActive(true); quizzUI.SetActive(false); scoreUI.SetActive(false); // Debug: play 0 index audio: category title ArabicFixer.Fix(_questionTitles[0], false, false); PlayQuestion(0); // Analytics stuff: Log Screen GoogleAnalyticsV4 GA = GoogleAnalyticsV4.instance; if (GA != null) { GA.LogScreen("Category " + GameData.GAME_CATEGORY.ToString()); } }
protected override void Awake() { base.Awake(); var controller = GetComponent <DatingController>(); controller.judgements.ObserveAdd() .Subscribe(judgement => { var profile = controller.currentProfileView.data; AnalyticsEvent.Custom("swipe", new Dictionary <string, object>() { { "on_profile", profile.name }, { "matched", judgement.Value.judgement == DatingProfileJudgement.Matched }, { "order", judgement.Index } }); var eventHitBuilder = new EventHitBuilder() .SetEventCategory("dating") .SetEventAction("swipe") .SetEventLabel(profile.name) .SetEventValue(judgement.Value.judgement == DatingProfileJudgement.Matched ? 1L : 0L) .SetCustomMetric(0, judgement.Index); GoogleAnalyticsV4.getInstance().LogEvent(eventHitBuilder); }) .AddTo(this); }
private string AddCampaignParameters <T>(HitBuilder <T> builder) { if (!trackingCodeSet) { return(""); } String url = ""; url += AddOptionalMPParameter(Fields.CAMPAIGN_NAME, builder.GetCampaignName()); url += AddOptionalMPParameter(Fields.CAMPAIGN_SOURCE, builder.GetCampaignSource()); url += AddOptionalMPParameter(Fields.CAMPAIGN_MEDIUM, builder.GetCampaignMedium()); url += AddOptionalMPParameter(Fields.CAMPAIGN_KEYWORD, builder.GetCampaignKeyword()); url += AddOptionalMPParameter(Fields.CAMPAIGN_CONTENT, builder.GetCampaignContent()); url += AddOptionalMPParameter(Fields.CAMPAIGN_ID, builder.GetCampaignID()); url += AddOptionalMPParameter(Fields.GCLID, builder.GetGclid()); url += AddOptionalMPParameter(Fields.DCLID, builder.GetDclid()); if (!String.IsNullOrEmpty(url)) { if (GoogleAnalyticsV4.belowThreshold(logLevel, GoogleAnalyticsV4.DebugMode.VERBOSE)) { Debug.Log("Added campaign parameters to hit. url:" + url); } } return(url); }
/* * Make request using yield and coroutine to prevent lock up waiting on request to return. */ public IEnumerator HandleWWW(WWW request) { while (!request.isDone) { yield return(request); if (request.responseHeaders.ContainsKey("STATUS")) { if (request.responseHeaders["STATUS"].Contains("200 OK")) { if (GoogleAnalyticsV4.belowThreshold(logLevel, GoogleAnalyticsV4.DebugMode.INFO)) { Debug.Log("Successfully sent Google Analytics hit with status: " + request.responseHeaders["STATUS"]); } } else { if (GoogleAnalyticsV4.belowThreshold(logLevel, GoogleAnalyticsV4.DebugMode.WARNING)) { Debug.LogWarning("Google Analytics hit request rejected with " + "status code " + request.responseHeaders["STATUS"]); } } } else { if (GoogleAnalyticsV4.belowThreshold(logLevel, GoogleAnalyticsV4.DebugMode.WARNING)) { Debug.LogWarning("Google Analytics hit request failed with error " + request.error); } } } }
void Start() { //currentImage = 0; rawImage.texture = imageArray[currentImage]; googleAnalytics = GameObject.Find("GAv4").GetComponent <GoogleAnalyticsV4>(); }
private void InitializeTracker() { if (!initialized) { instance = this; DontDestroyOnLoad(instance); // automatically set app parameters from player settings if they are left empty if (string.IsNullOrEmpty(productName)) { productName = Application.productName; } if (string.IsNullOrEmpty(bundleVersion)) { bundleVersion = Application.version; } Debug.Log("Initializing Google Analytics 0.2."); mpTracker.SetTrackingCode(trackingCode); mpTracker.SetBundleIdentifier(bundleIdentifier); mpTracker.SetAppName(productName); mpTracker.SetAppVersion(bundleVersion); mpTracker.SetLogLevelValue(logLevel); mpTracker.SetAnonymizeIP(anonymizeIP); mpTracker.SetDryRun(dryRun); mpTracker.InitializeTracker(); initialized = true; SetOnTracker(Fields.DEVELOPER_ID, "GbOCSs"); } }
// public methods public void EndGame() { // we ended the round and shall show End prompt audioPlayer.StopAudio(); questionTitleText.enabled = false; logoUI.enabled = false; quizzUI.SetActive(false); promptUI.SetActive(false); scoreUI.SetActive(true); Debug.Log("Total Yes: " + _yesCounter + ", Loaded Clips: " + _loadedClips.Count); float score = Mathf.RoundToInt((_yesCounter / _loadedClips.Count) * 100); Debug.Log("Score: " + score + "%"); scoreText.text = score.ToString() + "%"; // Anylitcs stuff GoogleAnalyticsV4 GA = GoogleAnalyticsV4.instance; if (GA != null) { GA.LogEvent("Complete " + GameData.GAME_CATEGORY, "User Id; " + GameData.USER_ID, score.ToString() + "%", 1); } }
/// <summary> /// Will only send data if not in Editor mode. /// </summary> /// <param name="GA">G.</param> /// <param name="DFVersion">Dwarf Fortress version.</param> /// <param name="pluginVersion">Plugin version.</param> public static void SendDeviceData(this GoogleAnalyticsV4 GA, string DFVersion, string pluginVersion) { #if !UNITY_EDITOR GA.LogEvent(new EventHitBuilder() .SetCustomDimension(1, SystemInfo.operatingSystemFamily.ToString()) .SetEventCategory("Graphics Card") .SetEventAction(SystemInfo.graphicsDeviceVendor) .SetEventLabel(SystemInfo.graphicsDeviceName) .SetEventValue(1) .Validate() ); GA.LogEvent(new EventHitBuilder() .SetCustomDimension(1, SystemInfo.operatingSystemFamily.ToString()) .SetEventCategory("Processor") .SetEventAction("Core number") .SetEventLabel(SystemInfo.processorCount.ToString()) .SetEventValue(1) .Validate() ); GA.LogEvent(new EventHitBuilder() .SetCustomDimension(1, SystemInfo.operatingSystemFamily.ToString()) .SetEventCategory("Processor") .SetEventAction("Core frequency") .SetEventLabel(SystemInfo.processorFrequency.ToString()) .SetEventValue(1) .Validate() ); GA.LogEvent(new EventHitBuilder() .SetCustomDimension(1, SystemInfo.operatingSystemFamily.ToString()) .SetEventCategory("OS Version") .SetEventAction(SystemInfo.operatingSystem) .SetEventLabel(SystemInfo.operatingSystem) .SetEventValue(1) .Validate() ); GA.LogEvent(new EventHitBuilder() .SetCustomDimension(1, SystemInfo.operatingSystemFamily.ToString()) .SetEventCategory("Program Version") .SetEventAction("Dwarf Fortress Version") .SetEventLabel(DFVersion) .SetEventValue(1) .Validate() ); GA.LogEvent(new EventHitBuilder() .SetCustomDimension(1, SystemInfo.operatingSystemFamily.ToString()) .SetEventCategory("Program Version") .SetEventAction("Plugin Version") .SetEventLabel(pluginVersion) .SetEventValue(1) .Validate() ); #endif }
public void Init() { _googleAnalytics = Object.FindObjectOfType <GoogleAnalyticsV4>(); if (_googleAnalytics == null) { throw new Exception("GoogleAnalyticsV4 object not found"); } }
void Start() { //BUILD PDF PATH FROM STREAMING ASSETS streamingPdf = PDFReader.AppDataPath + "/" + namePDF + ".pdf"; //localHTML = PDFReader.AppDataPath + "/" +"main.html"; googleAnalytics = GameObject.Find("GAv4").GetComponent <GoogleAnalyticsV4>(); }
void Start() { //BUILD PDF PATH FROM STREAMING ASSETS streamingPdf = PDFReader.AppDataPath + "/" + namePDF + ".pdf"; //localHTML = PDFReader.AppDataPath + "/" +"main.html"; googleAnalytics = GameObject.Find("GAv4").GetComponent<GoogleAnalyticsV4>(); }
private void Start() { googleAnalytics = GameObject.FindGameObjectsWithTag("GA")[0].GetComponent <GoogleAnalyticsV4>(); googleAnalytics.StartSession(); GM = this; soundManager.PlaySoundLoop(backgroundMusic, transform.position); player = GameObject.FindGameObjectWithTag("Player"); //cam = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<Camera>(); }
public void Init() { // fill GA GoogleAnalytics = UnityEngine.Object.FindObjectOfType <GoogleAnalyticsV4>(); if (GoogleAnalytics == null) { throw new Exception("GoogleAnalytics is not setted up!"); } }
public void Init() { // fill GA GoogleAnalytics = UnityEngine.Object.FindObjectOfType<GoogleAnalyticsV4>(); if (GoogleAnalytics == null) { throw new Exception("GoogleAnalytics is not setted up!"); } }
public void InitializeTracker() { if (String.IsNullOrEmpty(trackingCode)) { Debug.Log("No tracking code set - hits will not be set"); trackingCodeSet = false; return; } if (GoogleAnalyticsV4.IsLogLevelEnough(DebugMode.INFO)) { Debug.Log("Platform is not Android or iOS - " + "hits will be sent using measurement protocol."); } screenRes = Screen.width + "x" + Screen.height; clientId = SystemInfo.deviceUniqueIdentifier; string language = Application.systemLanguage.ToString(); optOut = false; #if !UNITY_WP8 CultureInfo[] cultureInfos = CultureInfo.GetCultures(CultureTypes.AllCultures); foreach (CultureInfo info in cultureInfos) { if (info.EnglishName == Application.systemLanguage.ToString()) { language = info.Name; } } #endif try { url = "https://www.google-analytics.com/collect?v=1" + AddRequiredMPParameter(Fields.LANGUAGE, language) + AddRequiredMPParameter(Fields.SCREEN_RESOLUTION, screenRes) + AddRequiredMPParameter(Fields.APP_NAME, appName) + AddRequiredMPParameter(Fields.TRACKING_ID, trackingCode) + AddRequiredMPParameter(Fields.APP_ID, bundleIdentifier) + AddRequiredMPParameter(Fields.CLIENT_ID, clientId) + AddRequiredMPParameter(Fields.APP_VERSION, appVersion); if (anonymizeIP) { url += AddOptionalMPParameter(Fields.ANONYMIZE_IP, 1); } if (GoogleAnalyticsV4.IsLogLevelEnough(DebugMode.VERBOSE)) { Debug.Log("Base URL for hits: " + url); } } catch (Exception) { if (GoogleAnalyticsV4.IsLogLevelEnough(DebugMode.WARNING)) { Debug.Log("Error building url."); } } }
public void LogException(ExceptionHitBuilder builder) { if (builder.Validate() == null) { return; } if (GoogleAnalyticsV4.belowThreshold(logLevel, GoogleAnalyticsV4.DebugMode.VERBOSE)) { Debug.Log("Logging exception."); } mpTracker.LogException(builder); }
public void LogScreen(AppViewHitBuilder builder) { if (builder.Validate() == null) { return; } if (GoogleAnalyticsV4.belowThreshold(logLevel, GoogleAnalyticsV4.DebugMode.VERBOSE)) { Debug.Log("Logging screen."); } mpTracker.LogScreen(builder); }
void Awake() { gav4 = AnalyticsAssistant.gav4; if (instance != null && instance != this) { Destroy(gameObject); return; } instance = this; layerGridTheirs = new LayerInfo("Grid Theirs"); source = GetComponent <CardboardAudioSource> (); }
// TODO: Error checking on initialization parameters private void InitializeTracker() { if (!initialized) { instance = this; DontDestroyOnLoad(instance); Debug.Log("Initializing Google Analytics 0.2."); productName = BuildSettings.Instance.title; bundleVersion = (Debug.isDebugBuild ? BuildSettings.Instance.build_date : BuildSettings.Instance.content_version) + (Debug.isDebugBuild ? "_Debug" : ""); #if UNITY_ANDROID && !UNITY_EDITOR androidTracker.SetTrackingCode(androidTrackingCode); androidTracker.SetAppName(productName); androidTracker.SetBundleIdentifier(bundleIdentifier); androidTracker.SetAppVersion(bundleVersion); androidTracker.SetDispatchPeriod(dispatchPeriod); androidTracker.SetSampleFrequency(sampleFrequency); androidTracker.SetLogLevelValue(logLevel); androidTracker.SetAnonymizeIP(anonymizeIP); androidTracker.SetAdIdCollection(enableAdId); androidTracker.SetDryRun(dryRun); androidTracker.InitializeTracker(); #elif UNITY_IPHONE && !UNITY_EDITOR iosTracker.SetTrackingCode(IOSTrackingCode); iosTracker.SetAppName(productName); iosTracker.SetBundleIdentifier(bundleIdentifier); iosTracker.SetAppVersion(bundleVersion); iosTracker.SetDispatchPeriod(dispatchPeriod); iosTracker.SetSampleFrequency(sampleFrequency); iosTracker.SetLogLevelValue(logLevel); iosTracker.SetAnonymizeIP(anonymizeIP); iosTracker.SetAdIdCollection(enableAdId); iosTracker.SetDryRun(dryRun); iosTracker.InitializeTracker(); #else mpTracker.SetTrackingCode(otherTrackingCode); mpTracker.SetBundleIdentifier(bundleIdentifier); mpTracker.SetAppName(productName); mpTracker.SetAppVersion(bundleVersion); mpTracker.SetLogLevelValue(logLevel); mpTracker.SetAnonymizeIP(anonymizeIP); mpTracker.SetDryRun(dryRun); mpTracker.InitializeTracker(); #endif initialized = true; SetOnTracker(Fields.DEVELOPER_ID, "GbOCSs"); } }
protected override void Awake() { base.Awake(); Debug.Log($"DialogueConversationController: Loaded {m_Sprites.Length} sprite(s)."); // When a text phase event is processed from the dialogue system and it didn't have choices, this will post // a delayed dialogue continuation to make it look like the other person was typing. Posts the length // of the output for the purposes of making an appropriate delay. var lastChoice = -1; CompositeDisposable subscriptions = null; m_ChatBoxController.choices .Subscribe(choice => { lastChoice = choice.index; }) .AddTo(this); profile .Where(item => item != null) .Subscribe(item => { m_DatingProfileView.data = item; m_ConversationController.conversantName = profile.Value.name; }) .AddTo(this); selectedDialogue .StartWith((DialogueItem)null) .Pairwise() .Subscribe(dialogues => { var oldDialogue = dialogues.Previous; var newDialogue = dialogues.Current; if (oldDialogue == newDialogue || newDialogue == null) { return; } subscriptions?.Dispose(); subscriptions = ResumeStory(newDialogue, oldDialogue); AnalyticsEvent.Custom("chat_with", new Dictionary <string, object>() { { "on_profile", profile.Value?.name } }); var eventHitBuilder1 = new EventHitBuilder() .SetEventCategory("conversation") .SetEventAction("chat_with") .SetEventLabel(profile.Value?.name); GoogleAnalyticsV4.getInstance().LogEvent(eventHitBuilder1); }) .AddTo(this); }
/// <summary> /// Undoes the last stamping action /// </summary> public void Undo() { drawingView.stampItems.RemoveAt(drawingView.stampItems.Count - 1); // Analytics var hit = new EventHitBuilder() .SetEventCategory("profile creator") .SetEventAction("undo") .SetEventValue(drawingView.stampItems.Count); GoogleAnalyticsV4.getInstance().LogEvent(hit); m_CanUndo.Value = drawingView.stampItems.Count > 0; }
public void InitializeTracker() { if (String.IsNullOrEmpty(trackingCode)) { Debug.Log("Google Analytics: No tracking code set for 'Other' platforms - hits will not be set"); trackingCodeSet = false; return; } if (GoogleAnalyticsV4.belowThreshold(logLevel, GoogleAnalyticsV4.DebugMode.INFO)) { Debug.Log("Google Analytics: Platform is not Android or iOS - " + "hits will be sent using measurement protocol."); } screenRes = Screen.width + "x" + Screen.height; if (string.IsNullOrEmpty(SystemInfo.deviceUniqueIdentifier)) { clientId = PlayerPrefs.GetString(playerPrefKeyUUID, GenerateId()); PlayerPrefs.SetString(playerPrefKeyUUID, clientId); } else { clientId = SystemInfo.deviceUniqueIdentifier; } string language = Application.systemLanguage.ToString(); optOut = false; try { url = baseUrl + AddRequiredMPParameter(Fields.LANGUAGE, language) + AddRequiredMPParameter(Fields.SCREEN_RESOLUTION, screenRes) + AddRequiredMPParameter(Fields.APP_NAME, appName) + AddRequiredMPParameter(Fields.TRACKING_ID, trackingCode) + AddRequiredMPParameter(Fields.APP_ID, bundleIdentifier) + AddRequiredMPParameter(Fields.CLIENT_ID, clientId) + AddRequiredMPParameter(Fields.APP_VERSION, appVersion); if (anonymizeIP) { url += AddOptionalMPParameter(Fields.ANONYMIZE_IP, 1); } if (GoogleAnalyticsV4.belowThreshold(logLevel, GoogleAnalyticsV4.DebugMode.VERBOSE)) { Debug.Log("Google Analytics: Base URL for hits: " + url); } } catch (Exception) { if (GoogleAnalyticsV4.belowThreshold(logLevel, GoogleAnalyticsV4.DebugMode.WARNING)) { Debug.Log("Google Analytics: Error building url."); } } }
protected override void Awake() { base.Awake(); var screenView = GetComponent <ScreenView>(); screenView.onScreenBeginTransition.AsObservable() .Subscribe(next => { var nextScreen = screenView.materialScreen[next]; AnalyticsEvent.ScreenVisit(nextScreen.gameObject.name); GoogleAnalyticsV4.getInstance().LogScreen(nextScreen.gameObject.name); }) .AddTo(this); }
void Awake() { if (INSTANCE != null && INSTANCE != this) { Destroy(gameObject); return; } INSTANCE = this; gav4 = GetComponent <GoogleAnalyticsV4> (); bool debug = Application.installMode == ApplicationInstallMode.DeveloperBuild || Application.installMode == ApplicationInstallMode.Editor; Debug.Log("Application.installMode = " + Application.installMode); // gav4.dryRun = debug; // Debug.Log ("gav4.dryRun = " + gav4.dryRun); // gav4.logLevel = debug ? GoogleAnalyticsV4.DebugMode.VERBOSE : GoogleAnalyticsV4.DebugMode.WARNING; // gav4.logLevel = GoogleAnalyticsV4.DebugMode.VERBOSE; gav4.logLevel = GoogleAnalyticsV4.DebugMode.WARNING; Debug.Log("gav4.logLevel = " + gav4.logLevel); #if UNITY_EDITOR if (Application.isEditor) { gav4.SetOnTracker(Fields.CLIENT_ID, "EDITOR"); } if (!gav4.bundleVersion.Equals(PlayerSettings.bundleVersion)) { throw new Exception( typeof(AnalyticsAssistant).Name + ".bundleVersion (" + gav4.bundleVersion + ") " + "!= " + typeof(PlayerSettings).Name + ".bundleVersion (" + PlayerSettings.bundleVersion + ")" + "\nExit play mode, click on " + typeof(AnalyticsAssistant).Name + " game object, then save scene to fix this"); } #endif var bundleVersion = gav4.bundleVersion + "-" + (debug ? "debug" : "prod"); gav4.SetOnTracker(Fields.APP_VERSION, bundleVersion); Debug.Log("bundleVersion=" + bundleVersion); if (debug) { gav4.SetOnTracker(Fields.DEVELOPER_ID, "fredsa"); } if (!Application.isEditor) { gav4.SetOnTracker(Fields.SCREEN_RESOLUTION, Screen.width + "x" + Screen.height + " " + Screen.dpi + "DPI"); } }
private void Init() { if (shouldInit) { ga = GetComponent <GoogleAnalyticsV4>(); ga.androidTrackingCode = "UA-125812104-1"; ga.IOSTrackingCode = "UA-125812104-1"; ga.otherTrackingCode = "UA-125812104-1"; ga.productName = Application.productName; ga.bundleIdentifier = Application.identifier; ga.bundleVersion = Application.version; ga.logLevel = GoogleAnalyticsV4.DebugMode.VERBOSE; ga.StartSession(); } }
void CheckValues() { GoogleAnalyticsV4 gav4 = (GoogleAnalyticsV4)target; bool dirty = false; dirty |= VerifyValue(ref gav4.androidTrackingCode, TRACKING_CODE); dirty |= VerifyValue(ref gav4.IOSTrackingCode, TRACKING_CODE); dirty |= VerifyValue(ref gav4.otherTrackingCode, TRACKING_CODE); dirty |= VerifyValue(ref gav4.productName, PlayerSettings.productName); dirty |= VerifyValue(ref gav4.bundleIdentifier, PlayerSettings.bundleIdentifier); dirty |= VerifyValue(ref gav4.bundleVersion, PlayerSettings.bundleVersion); if (dirty) { Debug.LogWarning("***" + target.name + " updated; Marking scene dirty"); serializedObject.ApplyModifiedProperties(); EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()); } }
private void SendGaHitWithMeasurementProtocol(string url) { if (String.IsNullOrEmpty(url)) { if (GoogleAnalyticsV4.IsLogLevelEnough(DebugMode.WARNING)) { Debug.Log("No tracking code set for 'Other' platforms - hit will not be sent."); } return; } if (dryRun || optOut) { if (GoogleAnalyticsV4.IsLogLevelEnough(DebugMode.WARNING)) { Debug.Log("Dry run or opt out enabled - hits will not be sent."); } return; } if (startSessionOnNextHit) { url += AddOptionalMPParameter(Fields.SESSION_CONTROL, "start"); startSessionOnNextHit = false; } else if (endSessionOnNextHit) { url += AddOptionalMPParameter(Fields.SESSION_CONTROL, "end"); endSessionOnNextHit = false; } // Add random z to avoid caching string newUrl = url + "&z=" + UnityEngine.Random.Range(0, 500); if (GoogleAnalyticsV4.IsLogLevelEnough(DebugMode.VERBOSE)) { Debug.Log(newUrl); } if (GoogleAnalyticsV4.instance.RunSynchronously) { HandleWWWSynchronously(UnityWebRequest.Post(newUrl, "")); } else { GoogleAnalyticsV4.instance.StartCoroutine(HandleWWW(UnityWebRequest.Post(newUrl, ""))); } }
private async void SendGaHitWithMeasurementProtocol(string url) { if (String.IsNullOrEmpty(url)) { if (GoogleAnalyticsV4.belowThreshold(logLevel, GoogleAnalyticsV4.DebugMode.WARNING)) { Debug.Log("No tracking code set for 'Other' platforms - hit will not be sent."); } return; } if (dryRun || optOut) { if (GoogleAnalyticsV4.belowThreshold(logLevel, GoogleAnalyticsV4.DebugMode.WARNING)) { Debug.Log("Dry run or opt out enabled - hits will not be sent."); } return; } if (startSessionOnNextHit) { url += AddOptionalMPParameter(Fields.SESSION_CONTROL, "start"); startSessionOnNextHit = false; } else if (endSessionOnNextHit) { url += AddOptionalMPParameter(Fields.SESSION_CONTROL, "end"); endSessionOnNextHit = false; } // Add random z to avoid caching string newUrl = url + "&z=" + UnityEngine.Random.Range(0, 500); if (GoogleAnalyticsV4.belowThreshold(logLevel, GoogleAnalyticsV4.DebugMode.VERBOSE)) { Debug.Log(newUrl); } if (!Application.isEditor) { var httpClient = new HttpClient(); var response = await httpClient.GetAsync(String.Format(newUrl)); response.EnsureSuccessStatusCode(); } }
public void LogTiming(TimingHitBuilder builder) { InitializeTracker(); if (builder.Validate() == null) { return; } if (GoogleAnalyticsV4.belowThreshold(logLevel, GoogleAnalyticsV4.DebugMode.VERBOSE)) { Debug.Log("Logging timing."); } #if UNITY_ANDROID && !UNITY_EDITOR androidTracker.LogTiming(builder); #elif UNITY_IPHONE && !UNITY_EDITOR iosTracker.LogTiming(builder); #else mpTracker.LogTiming(builder); #endif }
public void SetLogLevelValue(GoogleAnalyticsV4.DebugMode logLevel) { //this.logLevel = logLevel; }
public static bool belowThreshold(GoogleAnalyticsV4.DebugMode userLogLevel, GoogleAnalyticsV4.DebugMode comparelogLevel) { if (comparelogLevel == userLogLevel) { return true; } else if (userLogLevel == GoogleAnalyticsV4.DebugMode.ERROR) { return false; } else if (userLogLevel == GoogleAnalyticsV4.DebugMode.VERBOSE) { return true; } else if (userLogLevel == GoogleAnalyticsV4.DebugMode.WARNING && (comparelogLevel == GoogleAnalyticsV4.DebugMode.INFO || comparelogLevel == GoogleAnalyticsV4.DebugMode.VERBOSE)) { return false; } else if (userLogLevel == GoogleAnalyticsV4.DebugMode.INFO && (comparelogLevel == GoogleAnalyticsV4.DebugMode.VERBOSE)) { return false; } return true; }
// TODO: Error checking on initialization parameters private void InitializeTracker() { if (!initialized) { instance = this; DontDestroyOnLoad(instance); Debug.Log("Initializing Google Analytics 0.2."); #if UNITY_ANDROID && !UNITY_EDITOR androidTracker.SetTrackingCode(androidTrackingCode); androidTracker.SetAppName(productName); androidTracker.SetBundleIdentifier(bundleIdentifier); androidTracker.SetAppVersion(bundleVersion); androidTracker.SetDispatchPeriod(dispatchPeriod); androidTracker.SetSampleFrequency(sampleFrequency); androidTracker.SetLogLevelValue(logLevel); androidTracker.SetAnonymizeIP(anonymizeIP); androidTracker.SetAdIdCollection(enableAdId); androidTracker.SetDryRun(dryRun); androidTracker.InitializeTracker(); #elif UNITY_IPHONE && !UNITY_EDITOR iosTracker.SetTrackingCode(IOSTrackingCode); iosTracker.SetAppName(productName); iosTracker.SetBundleIdentifier(bundleIdentifier); iosTracker.SetAppVersion(bundleVersion); iosTracker.SetDispatchPeriod(dispatchPeriod); iosTracker.SetSampleFrequency(sampleFrequency); iosTracker.SetLogLevelValue(logLevel); iosTracker.SetAnonymizeIP(anonymizeIP); iosTracker.SetAdIdCollection(enableAdId); iosTracker.SetDryRun(dryRun); iosTracker.InitializeTracker(); #else mpTracker.SetTrackingCode(otherTrackingCode); mpTracker.SetBundleIdentifier(bundleIdentifier); mpTracker.SetAppName(productName); mpTracker.SetAppVersion(bundleVersion); mpTracker.SetLogLevelValue(logLevel); mpTracker.SetAnonymizeIP(anonymizeIP); mpTracker.SetDryRun(dryRun); mpTracker.InitializeTracker(); #endif initialized = true; SetOnTracker(Fields.DEVELOPER_ID, "GbOCSs"); } }
void Start() { //currentImage = 0; rawImage.texture = imageArray[currentImage]; googleAnalytics = GameObject.Find("GAv4").GetComponent<GoogleAnalyticsV4>(); }
void Start() { googleAnalytics = GameObject.Find("GAv4").GetComponent<GoogleAnalyticsV4>(); }