Skip to content

Instantly share code, notes, and snippets.

@marcusx2
Created September 8, 2020 20:01
Show Gist options
  • Save marcusx2/bba221f3ca3d8177cf7ef17e4148f322 to your computer and use it in GitHub Desktop.
Save marcusx2/bba221f3ca3d8177cf7ef17e4148f322 to your computer and use it in GitHub Desktop.
Google Analytics WebGL
//GoogleAnalytics.jslib
mergeInto(LibraryManager.library, {
sendGoogleAnalyticsEvent: function(hspt) {
gtag('event', 'Click', {
'event_category' : 'Hotspot',
'event_label' : Pointer_stringify(hspt)
});
}
});
//GoogleAnalytics.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Runtime.InteropServices;
public class GoogleAnalytics : MonoBehaviour
{
#if UNITY_WEBGL
[DllImport("__Internal")]
public static extern void sendGoogleAnalyticsEvent(string hotspot);
#endif
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment