Events edits
This commit is contained in:
@@ -11,9 +11,9 @@ namespace Darkmatter.Core.Contracts.Services.Analytics
|
||||
// Onboarding / activation funnel
|
||||
public const string IntroStarted = "intro_started";
|
||||
public const string IntroCompleted = "intro_completed";
|
||||
public const string TutorialStarted = "tutorial_started";
|
||||
public const string TutorialStarted = "tutorial_begin";
|
||||
public const string TutorialStepCompleted = "tutorial_step_completed";
|
||||
public const string TutorialCompleted = "tutorial_completed";
|
||||
public const string TutorialCompleted = "tutorial_complete";
|
||||
public const string PlayClicked = "play_clicked";
|
||||
public const string FirstDrawingStarted = "first_drawing_started";
|
||||
|
||||
@@ -32,10 +32,9 @@ namespace Darkmatter.Core.Contracts.Services.Analytics
|
||||
public const string ShapeAssembled = "shape_assembled";
|
||||
public const string ColorApplied = "color_applied";
|
||||
|
||||
// Progression & content. level_start is a GA4-recommended games event; level_complete is our
|
||||
// custom completion marker (GA4's own pair would be level_end + success).
|
||||
// Progression & content. level_start and level_end are GA4-recommended games events.
|
||||
public const string LevelStart = "level_start";
|
||||
public const string LevelComplete = "level_complete";
|
||||
public const string LevelComplete = "level_end";
|
||||
public const string AllContentCompleted = "all_content_completed";
|
||||
|
||||
// Gallery capture (pre-existing)
|
||||
|
||||
@@ -4,14 +4,14 @@ namespace Darkmatter.Core.Contracts.Services.Analytics
|
||||
/// Canonical analytics parameter keys. Pass a consistent set on every gameplay event so reports can
|
||||
/// answer "which drawing did people quit on", not just "how many quit". Each key used in reports must
|
||||
/// be registered as a Custom Dimension in the Firebase console. GA4 limit: 25 params per event.
|
||||
/// GA4-recommended events (level_start/level_complete/ad_impression) reuse GA4's reserved param names
|
||||
/// GA4-recommended events (level_start/level_end/ad_impression) reuse GA4's reserved param names
|
||||
/// (level_name, success, value, currency, ad_platform, ad_format, ad_unit_name) so they're recognised.
|
||||
/// </summary>
|
||||
public static class AnalyticsParams
|
||||
{
|
||||
// Content identity
|
||||
public const string DrawingId = "drawing_id";
|
||||
public const string LevelName = "level_name"; // GA4 reserved (level_start/level_complete)
|
||||
public const string LevelName = "level_name"; // GA4 reserved (level_start/level_end)
|
||||
|
||||
// Tutorial
|
||||
public const string StepId = "step_id";
|
||||
@@ -23,7 +23,7 @@ namespace Darkmatter.Core.Contracts.Services.Analytics
|
||||
public const string Attempts = "attempts";
|
||||
public const string ApplyIndex = "apply_index";
|
||||
public const string CompletionCount = "completion_count";
|
||||
public const string Success = "success"; // GA4 reserved (level_complete)
|
||||
public const string Success = "success"; // GA4 reserved (level_end)
|
||||
|
||||
// Monetization (GA4 ad_impression reserved names)
|
||||
public const string Value = "value";
|
||||
|
||||
@@ -39,6 +39,11 @@ namespace Darkmatter.Services.Ads
|
||||
[SerializeField, Min(0)]
|
||||
private int maxInterstitialsPerSession = 8;
|
||||
|
||||
[Tooltip(
|
||||
"Enable only after verifying Firebase/AdMob is not already auto-logging ad_impression for the same ads. Leaving this off avoids duplicate ad_impression counts in GA4/Firebase.")]
|
||||
[SerializeField]
|
||||
private bool logManualAdImpressionEvents;
|
||||
|
||||
public bool IsInitialized => _initialized;
|
||||
public event Action<AdFormat, AdLoadState> LoadStateChanged;
|
||||
|
||||
@@ -653,11 +658,12 @@ namespace Darkmatter.Services.Ads
|
||||
ad.OnAdClicked += () => LogAdClicked(format);
|
||||
}
|
||||
|
||||
// Ad revenue: GA4-recommended ad_impression carries value+currency from AdMob's paid callback —
|
||||
// this is what surfaces ad revenue in Firebase/GA4. Ad callbacks fire on the Unity main thread
|
||||
// (RaiseAdEventsOnUnityMainThread = true), so logging straight to analytics is safe.
|
||||
// AdMob/Firebase can auto-log ad_impression for linked apps. Manual logging is opt-in so one
|
||||
// shown ad does not become two GA4 ad_impression events.
|
||||
private void LogAdImpression(AdFormat format, AdValue value)
|
||||
{
|
||||
if (!logManualAdImpressionEvents) return;
|
||||
|
||||
_analytics?.LogEvent(AnalyticsEvents.AdImpression, new Dictionary<string, object>
|
||||
{
|
||||
[AnalyticsParams.AdPlatform] = "AdMob",
|
||||
@@ -736,4 +742,4 @@ namespace Darkmatter.Services.Ads
|
||||
LoadStateChanged?.Invoke(format, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ namespace Darkmatter.Services.Analytics
|
||||
if (dur >= 0f) p[AnalyticsParams.DurationSeconds] = dur;
|
||||
_analytics.LogEvent(AnalyticsEvents.DrawingCompleted, p);
|
||||
|
||||
// Companion to GA4's level_start (custom name — GA4's own pair would be level_end).
|
||||
// Companion to GA4's level_start.
|
||||
_analytics.LogEvent(AnalyticsEvents.LevelComplete, new Dictionary<string, object>
|
||||
{
|
||||
[AnalyticsParams.LevelName] = s.TemplateId,
|
||||
@@ -176,15 +176,21 @@ namespace Darkmatter.Services.Analytics
|
||||
if (PlayerPrefs.GetInt(AllContentKey, 0) == 1) return; // once ever
|
||||
PlayerPrefs.SetInt(AllContentKey, 1);
|
||||
PlayerPrefs.Save();
|
||||
_analytics.LogEvent(AnalyticsEvents.AllContentCompleted,
|
||||
AnalyticsParams.CompletionCount, s.CompletedCount.ToString());
|
||||
_analytics.LogEvent(AnalyticsEvents.AllContentCompleted, new Dictionary<string, object>
|
||||
{
|
||||
[AnalyticsParams.CompletionCount] = s.CompletedCount,
|
||||
});
|
||||
}
|
||||
|
||||
private void OnGallerySaveCompleted(GallerySaveCompletedSignal s)
|
||||
{
|
||||
_analytics.LogEvent(AnalyticsEvents.GallerySaveCompleted, AnalyticsParams.Success, s.Success ? "true" : "false");
|
||||
// Prefer the id carried by the signal: art-book saves happen with no active drawing.
|
||||
string drawingId = string.IsNullOrEmpty(s.TemplateId) ? _activeDrawingId ?? string.Empty : s.TemplateId;
|
||||
_analytics.LogEvent(AnalyticsEvents.GallerySaveCompleted, new Dictionary<string, object>
|
||||
{
|
||||
[AnalyticsParams.DrawingId] = drawingId,
|
||||
[AnalyticsParams.Success] = s.Success ? 1 : 0,
|
||||
});
|
||||
_analytics.LogEvent(AnalyticsEvents.DrawingSaved, new Dictionary<string, object>
|
||||
{
|
||||
[AnalyticsParams.DrawingId] = drawingId,
|
||||
|
||||
Reference in New Issue
Block a user