Google Analytics Measurement Protocol 1.2.0
Google Analytics plugin for Unreal Engine, using a native cross-platform implementation of the Measurement Protocol.
Loading...
Searching...
No Matches
Static Public Member Functions | Friends | List of all members
UGoogleAnalyticsMPStatics Class Reference

Google Analytics Measurement Protocol static methods that can be called from both Blueprint and C++. More...

#include <GAMPStatics.h>

Inheritance diagram for UGoogleAnalyticsMPStatics:

Static Public Member Functions

static class UGoogleAnalyticsMPAttributesFilterGetAttributesFilter ()
 Get the Attributes Filter instantiated internally (. More...
 
Session handling
static void StartSession (const TMap< FString, FString > &Attributes)
 Start a user session. More...
 
static void EndSession (const TMap< FString, FString > &Attributes)
 Ends a user session. More...
 
static void ResetPersistentData ()
 Reset any persistent and cached data. More...
 
static void SetOptOut (bool bOptOut)
 Set if "opt-out" from all analytics logging. More...
 
static bool GetOptOut ()
 Get the status of the "opt out" option. More...
 
static void SetUserID (const FString &UserID)
 Set the know unique identifier of the current user. More...
 
Batching
static void BeginBatch ()
 Begin a batch of events, optimizing their sending when explicitly ending the batch. More...
 
static void EndBatch ()
 End a batch of events, sending the batched events. More...
 
Events logging
static void RecordNamedEvent (const FString &EventName, const TMap< FString, FString > &Attributes)
 Records a named "event". More...
 
static void RecordScreenView (const FString &ScreenName, const TMap< FString, FString > &Attributes)
 Records a "screenview" hit type to log how the user is moving inside your game/application. More...
 
static void RecordStructuredEvent (const FString &EventCategory, const FString &EventAction, const FString &EventLabel, const int32 EventValue, const TMap< FString, FString > &Attributes)
 Records an "event" hit type [deprecated, UA only]. More...
 
static void RecordStructuredEventWithValue (const FString &EventCategory, const FString &EventAction, const FString &EventLabel, const int32 EventValue, const TMap< FString, FString > &Attributes)
 Records an "event" hit type (with an associated value) [deprecated, UA only]. More...
 
static void RecordStructuredEvent (const FString &EventCategory, const FString &EventAction, const FString &EventLabel, const TMap< FString, FString > &Attributes)
 Records an "event" hit type [deprecated, UA only]. More...
 
E-commerce
static void RecordECommerceViewProduct (const FGoogleAnalyticsMPPurchaseInfo &PurchaseInfo)
 Record the view of a purchasable product (with real money), before starting the checkout action. More...
 
static void RecordECommerceBeginCheckout (const FGoogleAnalyticsMPPurchaseInfo &PurchaseInfo)
 Record the add-to-cart/checkout of a purchase (with real money), before completing the purchase. More...
 
static void RecordECommercePurchase (const FGoogleAnalyticsMPPurchaseInfo &PurchaseInfo)
 Record the completion of a purchase (with real money). More...
 

Friends

class IGoogleAnalyticsMPProvider
 

Detailed Description

Google Analytics Measurement Protocol static methods that can be called from both Blueprint and C++.

This class provides the plugin API, including methods for ordinary event logging and methods to manage advanced features like session handling, opt-out, cached storage, etc.

Member Function Documentation

◆ BeginBatch()

static void UGoogleAnalyticsMPStatics::BeginBatch ( )
static

Begin a batch of events, optimizing their sending when explicitly ending the batch.

You MUST call EndBatch(). Calls can be nested, as long as they're correctly paired.

◆ EndBatch()

static void UGoogleAnalyticsMPStatics::EndBatch ( )
static

End a batch of events, sending the batched events.

In general, the top-level EndBatch() call is the one that will ensure that all the batched events are sent.

◆ EndSession()

static void UGoogleAnalyticsMPStatics::EndSession ( const TMap< FString, FString > &  Attributes)
static

Ends a user session.

If UGoogleAnalyticsMPSettings::bAutoSessionHandling is false, you must call this method when your application ends.

◆ GetAttributesFilter()

static class UGoogleAnalyticsMPAttributesFilter * UGoogleAnalyticsMPStatics::GetAttributesFilter ( )
static

Get the Attributes Filter instantiated internally (.

See also
UGoogleAnalyticsMPAttributesFilter). It can be null.
Returns
the UGoogleAnalyticsMPAttributesFilter instance if the UGoogleAnalyticsMPSettings::AttributesFilterClass was set in settings, nullptr otherwise.

◆ GetOptOut()

static bool UGoogleAnalyticsMPStatics::GetOptOut ( )
static

Get the status of the "opt out" option.

See also
SetOptOut() for more information.
Returns
True if no data to Google Analytics is sent and calls to log events are silently ignored.

◆ RecordECommerceBeginCheckout()

static void UGoogleAnalyticsMPStatics::RecordECommerceBeginCheckout ( const FGoogleAnalyticsMPPurchaseInfo PurchaseInfo)
static

Record the add-to-cart/checkout of a purchase (with real money), before completing the purchase.

Parameters
PurchaseInfoThe information about items for which the user has started the checkout process.

RecordECommerceViewProduct() MUST be called before this one. If the purchase is confirmed/completed, a call to RecordECommercePurchase() MUST be done.

◆ RecordECommercePurchase()

static void UGoogleAnalyticsMPStatics::RecordECommercePurchase ( const FGoogleAnalyticsMPPurchaseInfo PurchaseInfo)
static

Record the completion of a purchase (with real money).

Parameters
PurchaseInfoThe purchase information about the transaction.

RecordECommerceBeginCheckout() MUST be called before this one.

◆ RecordECommerceViewProduct()

static void UGoogleAnalyticsMPStatics::RecordECommerceViewProduct ( const FGoogleAnalyticsMPPurchaseInfo PurchaseInfo)
static

Record the view of a purchasable product (with real money), before starting the checkout action.

Parameters
PurchaseInfoThe information about the item(s) the user is currently seeing.

This is the first method that MUST be called in a purchase journey. If the user proceed with the purchase, a call to RecordECommerceBeginCheckout() MUST be done.

◆ RecordNamedEvent()

static void UGoogleAnalyticsMPStatics::RecordNamedEvent ( const FString &  EventName,
const TMap< FString, FString > &  Attributes 
)
static

Records a named "event".

Parameters
EventNameEvent name. Attention: GA4 has strict naming rules and reserved event names (read more), we suggest to use a unique common safe prefix for custom events.
AttributesOptional auxiliary Google Analytics Measurement Protocol attributes (for GA4 see https://developers.google.com/analytics/devguides/collection/ga4/reference/events?client_type=gtag; for UA see https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters).
Attention
For UA: this is the low level interface to log an "event" hit type. In general, it's advised to use RecordStructuredEvent() or RecordStructuredEventWithValue() instead when possible, Google Universal Analytics REQUIRES some attributes with events and wrong usages of this method could result in missed logged events.

◆ RecordScreenView()

static void UGoogleAnalyticsMPStatics::RecordScreenView ( const FString &  ScreenName,
const TMap< FString, FString > &  Attributes 
)
static

Records a "screenview" hit type to log how the user is moving inside your game/application.

In Unreal Engine, you can use it to track the user navigation between menus and maps.

Parameters
ScreenNameThe screen name as logged in Google Analytics.
AttributesOptional auxiliary Google Analytics Measurement Protocol attributes (for GA4 see https://developers.google.com/analytics/devguides/collection/ga4/reference/events?client_type=gtag; for UA see https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters).

◆ RecordStructuredEvent() [1/2]

static void UGoogleAnalyticsMPStatics::RecordStructuredEvent ( const FString &  EventCategory,
const FString &  EventAction,
const FString &  EventLabel,
const int32  EventValue,
const TMap< FString, FString > &  Attributes 
)
inlinestatic

Records an "event" hit type [deprecated, UA only].

Events are user interactions with content other than screen views.

Attention
GA4 doesn't support Structured Events, use RecordNamedEvent() instead.

Read more about Google Analytics events here: https://support.google.com/analytics/answer/1033068?hl=en. To add further custom data to events, read about the Custom Dimensions and Metrics: https://support.google.com/analytics/answer/2709828?hl=en.

If you must log an event with a numeric value associated, you can use RecordStructuredEventWithValue().

Parameters
EventCategoryEvent category (required, it must not be empty).
EventActionEvent action (required, it must not be empty).
EventLabelEvent label (optional, can be empty).
EventValueEvent value (required, use the other RecordEvent* methods if the value must not be logged).
AttributesOptional auxiliary Google Analytics Measurement Protocol attributes (for GA4 see https://developers.google.com/analytics/devguides/collection/ga4/reference/events?client_type=gtag; for UA see https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters).

◆ RecordStructuredEvent() [2/2]

static void UGoogleAnalyticsMPStatics::RecordStructuredEvent ( const FString &  EventCategory,
const FString &  EventAction,
const FString &  EventLabel,
const TMap< FString, FString > &  Attributes 
)
inlinestatic

Records an "event" hit type [deprecated, UA only].

Events are user interactions with content other than screen views.

Attention
GA4 doesn't support Structured Events, use RecordNamedEvent() instead.

Read more about Google Analytics events here: https://support.google.com/analytics/answer/1033068?hl=en.

Parameters
EventCategoryEvent category (required, it must not be empty).
EventActionEvent action (required, it must not be empty).
EventLabelEvent label (optional, can be empty).
AttributesOptional auxiliary Google Analytics Measurement Protocol attributes (for GA4 see https://developers.google.com/analytics/devguides/collection/ga4/reference/events?client_type=gtag; for UA see https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters).

◆ RecordStructuredEventWithValue()

static void UGoogleAnalyticsMPStatics::RecordStructuredEventWithValue ( const FString &  EventCategory,
const FString &  EventAction,
const FString &  EventLabel,
const int32  EventValue,
const TMap< FString, FString > &  Attributes 
)
inlinestatic

Records an "event" hit type (with an associated value) [deprecated, UA only].

Events are user interactions with content other than screen views.

Attention
GA4 doesn't support Structured Events, use RecordNamedEvent() instead.

Read more about Google Analytics events here: https://support.google.com/analytics/answer/1033068?hl=en. To add further custom data to events, read about the Custom Dimensions and Metrics: https://support.google.com/analytics/answer/2709828?hl=en.

Parameters
EventCategoryEvent category (required, it must not be empty).
EventActionEvent action (required, it must not be empty).
EventLabelEvent label (optional, can be empty).
EventValueEvent value (required, use the other RecordEvent* methods if the value must not be logged).
AttributesOptional auxiliary Google Analytics Measurement Protocol attributes (for GA4 see https://developers.google.com/analytics/devguides/collection/ga4/reference/events?client_type=gtag; for UA see https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters).

◆ ResetPersistentData()

static void UGoogleAnalyticsMPStatics::ResetPersistentData ( )
static

Reset any persistent and cached data.

Call this method to remove any stored data and reset the system to a clean and fresh state. This includes resetting the "opt-out" option (see SetOptOut()), any cached User ID and Client ID, etc.

◆ SetOptOut()

static void UGoogleAnalyticsMPStatics::SetOptOut ( bool  bOptOut)
static

Set if "opt-out" from all analytics logging.

This is a "kill switch" method that can be used to silently ignore all calls made to log events on Google Analytics. It's useful if you want to provide to the user a simple option to opt-out from the analytics. The value is saved in the persistent storage. The default initial value is set in the project settings (see UGoogleAnalyticsMPSettings::bOptOutDefault).

Parameters
bOptOutSet to true to stop sending data to Google Analytics.

◆ SetUserID()

static void UGoogleAnalyticsMPStatics::SetUserID ( const FString &  UserID)
static

Set the know unique identifier of the current user.

The value is saved in the persistent storage accordingly to the setting UGoogleAnalyticsMPSettings::bPersistentUserID.

See also
for GA4: https://support.google.com/analytics/answer/9213390, https://developers.google.com/analytics/devguides/collection/ga4/reference/events?client_type=gtag
for UA https://support.google.com/analytics/answer/3123662?hl=en, https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#uid
Parameters
UserIDThe known identifier for a user, or an empty string to clear it. It must not itself be PII (Personally Identifiable Information). If you have only PII (e.g. the user email address), we suggest to pass a proper hash string of it.

◆ StartSession()

static void UGoogleAnalyticsMPStatics::StartSession ( const TMap< FString, FString > &  Attributes)
static

Start a user session.

If UGoogleAnalyticsMPSettings::bAutoSessionHandling is false, you must call this method when your application starts.


The documentation for this class was generated from the following file: