UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
IAnalyticsProvider Class Referenceabstract

#include <IAnalyticsProvider.h>

+ Inheritance diagram for IAnalyticsProvider:

Public Member Functions

bool StartSession ()
 
virtual bool StartSession (const TArray< FAnalyticsEventAttribute > &Attributes)=0
 
bool StartSession (const FAnalyticsEventAttribute &Attribute)
 
bool StartSession (const FString &ParamName, const FString &ParamValue)
 
virtual void EndSession ()=0
 
virtual FString GetSessionID () const =0
 
virtual bool SetSessionID (const FString &InSessionID)=0
 
virtual void FlushEvents ()=0
 
virtual void SetUserID (const FString &InUserID)=0
 
virtual FString GetUserID () const =0
 
virtual void SetDefaultEventAttributes (TArray< FAnalyticsEventAttribute > &&Attributes)=0
 
virtual TArray< FAnalyticsEventAttributeGetDefaultEventAttributesSafe () const =0
 
virtual int32 GetDefaultEventAttributeCount () const =0
 
virtual FAnalyticsEventAttribute GetDefaultEventAttribute (int AttributeIndex) const =0
 
virtual void SetBuildInfo (const FString &InBuildInfo)
 
virtual void SetGender (const FString &InGender)
 
virtual void SetLocation (const FString &InLocation)
 
virtual void SetAge (const int32 InAge)
 
virtual void RecordEvent (const FString &EventName, const TArray< FAnalyticsEventAttribute > &Attributes)=0
 
virtual void RecordEvent (const FString &EventName, const TArray< FAnalyticsEventAttribute > &Attributes, EAnalyticsRecordEventMode Mode)
 
void RecordEvent (const FString &EventName)
 
void RecordEvent (const FString &EventName, const FAnalyticsEventAttribute &Attribute)
 
void RecordEvent (const FString &EventName, const FString &ParamName, const FString &ParamValue)
 
virtual void RecordItemPurchase (const FString &ItemId, const FString &Currency, int PerItemCost, int ItemQuantity)
 
virtual void RecordItemPurchase (const FString &ItemId, int ItemQuantity, const TArray< FAnalyticsEventAttribute > &EventAttrs)
 
void RecordItemPurchase (const FString &ItemId, int ItemQuantity)
 
virtual void RecordCurrencyPurchase (const FString &GameCurrencyType, int GameCurrencyAmount, const FString &RealCurrencyType, float RealMoneyCost, const FString &PaymentProvider)
 
virtual void RecordCurrencyPurchase (const FString &GameCurrencyType, int GameCurrencyAmount, const TArray< FAnalyticsEventAttribute > &EventAttrs)
 
virtual void RecordCurrencyPurchase (const FString &GameCurrencyType, int GameCurrencyAmount)
 
virtual void RecordCurrencyGiven (const FString &GameCurrencyType, int GameCurrencyAmount)
 
virtual void RecordCurrencyGiven (const FString &GameCurrencyType, int GameCurrencyAmount, const TArray< FAnalyticsEventAttribute > &EventAttrs)
 
virtual void RecordError (const FString &Error, const TArray< FAnalyticsEventAttribute > &EventAttrs)
 
virtual void RecordError (const FString &Error)
 
virtual void RecordProgress (const FString &ProgressType, const TArray< FString > &ProgressHierarchy, const TArray< FAnalyticsEventAttribute > &EventAttrs)
 
virtual void RecordProgress (const FString &ProgressType, const FString &ProgressHierarchy)
 
virtual void RecordProgress (const FString &ProgressType, const FString &ProgressHierarchy, const TArray< FAnalyticsEventAttribute > &EventAttrs)
 
virtual ~IAnalyticsProvider ()
 

Detailed Description

Generic interface for an analytics provider. Other modules can define more and register them with this module. See FAnalytics for details.

Easiest way to use this is like so:

// MakeAnalyticsEventAttributeArray is a convenient way to efficiently make an array of attributes // Since it returns an unnamed temporary, the compiler automatically selects the move-aware version. AnalyticsProvider->RecordEvent(TEXT("MyEvent"), MakeAnalyticsEventAttributeArray("Attr1", "Value1", ... )); or: TArray<FAnalyticEventAttribute> Attrs; Attrs.Add(...); AnalyticsProvider->RecordEvent(TEXT("MyEvent"), Attrs);

Several APIs build off the pure virtual ones. The following pure virtuals must be implemented by a derived class.

virtual bool StartSession(const TArray<FAnalyticsEventAttribute>& Attributes)
virtual void EndSession()
virtual FString GetSessionID() const
virtual bool SetSessionID(const FString& InSessionID)
virtual void FlushEvents()
virtual void SetUserID(const FString& InUserID)
virtual FString GetUserID() const

virtual void RecordEvent(const FString& EventName, const TArray<FAnalyticsEventAttribute>& Attributes)

There are several other methods to record specific types of events. They were added for legacy reasons to support specific third party implementations. Derived classes generally do not have to worry about them.

Constructor & Destructor Documentation

◆ ~IAnalyticsProvider()

virtual IAnalyticsProvider::~IAnalyticsProvider ( )
inlinevirtual

Member Function Documentation

◆ EndSession()

virtual void IAnalyticsProvider::EndSession ( )
pure virtual

Ends the session. Usually no need to call explicitly, as the provider should do this for you when the instance is destroyed.

Implemented in FAnalyticsProviderLog, and FAnalyticsProviderBroadcast.

◆ FlushEvents()

virtual void IAnalyticsProvider::FlushEvents ( )
pure virtual

Flush any cached events to the analytics provider.

Note that not all providers support explicitly sending any cached events. In which case this method does nothing.

Implemented in FAnalyticsProviderLog, and FAnalyticsProviderBroadcast.

◆ GetDefaultEventAttribute()

virtual FAnalyticsEventAttribute IAnalyticsProvider::GetDefaultEventAttribute ( int  AttributeIndex) const
pure virtual

Used with GetDefaultEventAttributeCount to iterate over the default attributes.

Range checking is not done, similar to TArray. Use GetDefaultAttributeCount() first!

Returns
one attribute of the default attributes so we don't have to copy the entire attribute array.

Implemented in FAnalyticsProviderLog, and FAnalyticsProviderBroadcast.

◆ GetDefaultEventAttributeCount()

virtual int32 IAnalyticsProvider::GetDefaultEventAttributeCount ( ) const
pure virtual

Used with GetDefaultAttribute to iterate over the default attributes.

Returns
the number of default attributes are currently being applied.

Implemented in FAnalyticsProviderLog, and FAnalyticsProviderBroadcast.

◆ GetDefaultEventAttributesSafe()

virtual TArray< FAnalyticsEventAttribute > IAnalyticsProvider::GetDefaultEventAttributesSafe ( ) const
pure virtual
Returns
the current array of default attributes.

Implemented in FAnalyticsProviderLog, and FAnalyticsProviderBroadcast.

◆ GetSessionID()

virtual FString IAnalyticsProvider::GetSessionID ( ) const
pure virtual

Gets the opaque session identifier string for the provider.

Implemented in FAnalyticsProviderLog, and FAnalyticsProviderBroadcast.

◆ GetUserID()

virtual FString IAnalyticsProvider::GetUserID ( ) const
pure virtual

Gset the current UserID. Use -ANALYTICSUSERID=<Name> command line to force the provider to use a specific UserID for this run.

Implemented in FAnalyticsProviderLog, and FAnalyticsProviderBroadcast.

◆ RecordCurrencyGiven() [1/2]

virtual void IAnalyticsProvider::RecordCurrencyGiven ( const FString &  GameCurrencyType,
int  GameCurrencyAmount 
)
inlinevirtual

Record a gift of in-game currency from the game itself.

Note that not all providers support currency events. In this case this method is equivalent to sending a regular event with name "Currency Given".

Parameters
GameCurrencyType- type of in game currency given, should be registered with the provider first.
GameCurrencyAmount- amount of in game currency given.

◆ RecordCurrencyGiven() [2/2]

virtual void IAnalyticsProvider::RecordCurrencyGiven ( const FString &  GameCurrencyType,
int  GameCurrencyAmount,
const TArray< FAnalyticsEventAttribute > &  EventAttrs 
)
inlinevirtual

Record a gift of in-game currency from the game itself.

Note that not all providers support currency events. In this case this method is equivalent to sending a regular event with name "Currency Given".

Parameters
GameCurrencyType- type of in game currency given, should be registered with the provider first.
GameCurrencyAmount- amount of in game currency given.
EventAttrs- a list of key/value pairs to assign to this event

◆ RecordCurrencyPurchase() [1/3]

virtual void IAnalyticsProvider::RecordCurrencyPurchase ( const FString &  GameCurrencyType,
int  GameCurrencyAmount 
)
inlinevirtual

Record an in-game purchase of a an item.

Note that not all providers support item purchase events. In this case this method is equivalent to sending a regular event with name "Item Purchase".

Parameters
ItemId- the ID of the item, should be registered with the provider first.
ItemQuantity- the number of Items purchased.

◆ RecordCurrencyPurchase() [2/3]

virtual void IAnalyticsProvider::RecordCurrencyPurchase ( const FString &  GameCurrencyType,
int  GameCurrencyAmount,
const FString &  RealCurrencyType,
float  RealMoneyCost,
const FString &  PaymentProvider 
)
inlinevirtual

Record a purchase of in-game currency using real-world money.

Note that not all providers support currency events. In this case this method is equivalent to sending a regular event with name "Currency Purchase".

Parameters
GameCurrencyType- type of in game currency purchased, should be registered with the provider first.
GameCurrencyAmount- amount of in game currency purchased.
RealCurrencyType- real-world currency type (like a 3-character ISO 4217 currency code, but provider dependent).
RealMoneyCost- cost of the currency in real world money, expressed in RealCurrencyType units.
PaymentProvider- Provider who brokered the transaction. Generally arbitrary, but examples are PayPal, Facebook Credits, App Store, etc.

◆ RecordCurrencyPurchase() [3/3]

virtual void IAnalyticsProvider::RecordCurrencyPurchase ( const FString &  GameCurrencyType,
int  GameCurrencyAmount,
const TArray< FAnalyticsEventAttribute > &  EventAttrs 
)
inlinevirtual

Record a purchase of in-game currency using real-world money.

Note that not all providers support currency events. In this case this method is equivalent to sending a regular event with name "Currency Purchase".

Parameters
GameCurrencyType- type of in game currency purchased, should be registered with the provider first.
GameCurrencyAmount- amount of in game currency purchased.
EventAttrs- a list of key/value pairs to assign to this event

◆ RecordError() [1/2]

virtual void IAnalyticsProvider::RecordError ( const FString &  Error)
inlinevirtual

Records an error that has happened in the game

Note that not all providers support all events. In this case this method is equivalent to sending a regular event with name "Game Error".

Parameters
Error- the error string to record

◆ RecordError() [2/2]

virtual void IAnalyticsProvider::RecordError ( const FString &  Error,
const TArray< FAnalyticsEventAttribute > &  EventAttrs 
)
inlinevirtual

Records an error that has happened in the game

Note that not all providers support all events. In this case this method is equivalent to sending a regular event with name "Game Error".

Parameters
Error- the error string to record
EventAttrs- a list of key/value pairs to assign to this event

◆ RecordEvent() [1/5]

void IAnalyticsProvider::RecordEvent ( const FString &  EventName)
inline

Overload for RecordEvent that takes no parameters

Parameters
EventNamename of the event

◆ RecordEvent() [2/5]

void IAnalyticsProvider::RecordEvent ( const FString &  EventName,
const FAnalyticsEventAttribute Attribute 
)
inline

Overload for RecordEvent that takes a single attribute

Parameters
EventNamename of the event
Attributeattribute name and value

◆ RecordEvent() [3/5]

void IAnalyticsProvider::RecordEvent ( const FString &  EventName,
const FString &  ParamName,
const FString &  ParamValue 
)
inline

Overload for RecordEvent that takes a single name/value pair

Parameters
EventNamename of the event
ParamNameattribute name
ParamValueattribute value

◆ RecordEvent() [4/5]

virtual void IAnalyticsProvider::RecordEvent ( const FString &  EventName,
const TArray< FAnalyticsEventAttribute > &  Attributes 
)
pure virtual

Records a named event with an array of attributes

Parameters
EventNamename of the event
Attributesarray of attribute name/value pairs

Implemented in FAnalyticsProviderBroadcast, and FAnalyticsProviderLog.

◆ RecordEvent() [5/5]

virtual void IAnalyticsProvider::RecordEvent ( const FString &  EventName,
const TArray< FAnalyticsEventAttribute > &  Attributes,
EAnalyticsRecordEventMode  Mode 
)
inlinevirtual

RecordEvent overload to allow platforms to support events that are immediately sent

Parameters
EventNamename of the event
Attributesarray of attribute name/value pairs
Modethe record event mode, Cached or Immediate
See also
EAnalyticsRecordEventMode

Reimplemented in FAnalyticsProviderBroadcast.

◆ RecordItemPurchase() [1/3]

virtual void IAnalyticsProvider::RecordItemPurchase ( const FString &  ItemId,
const FString &  Currency,
int  PerItemCost,
int  ItemQuantity 
)
inlinevirtual

Record an in-game purchase of a an item.

Note that not all providers support item purchase events. In this case this method is equivalent to sending a regular event with name "Item Purchase".

Parameters
ItemId- the ID of the item, should be registered with the provider first.
Currency- the currency of the purchase (ie, Gold, Coins, etc), should be registered with the provider first.
PerItemCost- the cost of one item in the currency given.
ItemQuantity- the number of Items purchased.

◆ RecordItemPurchase() [2/3]

void IAnalyticsProvider::RecordItemPurchase ( const FString &  ItemId,
int  ItemQuantity 
)
inline

Record an in-game purchase of a an item.

Note that not all providers support item purchase events. In this case this method is equivalent to sending a regular event with name "Item Purchase".

Parameters
ItemId- the ID of the item, should be registered with the provider first.
ItemQuantity- the number of Items purchased.

◆ RecordItemPurchase() [3/3]

virtual void IAnalyticsProvider::RecordItemPurchase ( const FString &  ItemId,
int  ItemQuantity,
const TArray< FAnalyticsEventAttribute > &  EventAttrs 
)
inlinevirtual

Record an in-game purchase of a an item.

Note that not all providers support item purchase events. In this case this method is equivalent to sending a regular event with name "Item Purchase".

Parameters
ItemId- the ID of the item, should be registered with the provider first.
ItemQuantity- the number of Items purchased.
EventAttrs- a list of key/value pairs to assign to this event

◆ RecordProgress() [1/3]

virtual void IAnalyticsProvider::RecordProgress ( const FString &  ProgressType,
const FString &  ProgressHierarchy 
)
inlinevirtual

Record a player progression event that has happened in the game

Note that not all providers support all events. In this case this method is equivalent to sending a regular event with name "Progression".

Parameters
Error- the error string to record

◆ RecordProgress() [2/3]

virtual void IAnalyticsProvider::RecordProgress ( const FString &  ProgressType,
const FString &  ProgressHierarchy,
const TArray< FAnalyticsEventAttribute > &  EventAttrs 
)
inlinevirtual

Record a player progression event that has happened in the game

Note that not all providers support all events. In this case this method is equivalent to sending a regular event with name "Progression".

Parameters
Error- the error string to record

◆ RecordProgress() [3/3]

virtual void IAnalyticsProvider::RecordProgress ( const FString &  ProgressType,
const TArray< FString > &  ProgressHierarchy,
const TArray< FAnalyticsEventAttribute > &  EventAttrs 
)
inlinevirtual

Record a player progression event that has happened in the game

Note that not all providers support all events. In this case this method is equivalent to sending a regular event with name "Progression".

Parameters
Error- the error string to record

◆ SetAge()

virtual void IAnalyticsProvider::SetAge ( const int32  InAge)
inlinevirtual

Sets the location the game believes the user is playing in as part of the session

◆ SetBuildInfo()

virtual void IAnalyticsProvider::SetBuildInfo ( const FString &  InBuildInfo)
inlinevirtual

Sets a user defined string as the build information/version for the session

◆ SetDefaultEventAttributes()

virtual void IAnalyticsProvider::SetDefaultEventAttributes ( TArray< FAnalyticsEventAttribute > &&  Attributes)
pure virtual

Sets an array of attributes that will automatically be appended to any event that is sent. Logical effect is like adding them to all events before calling RecordEvent. Practically, it is implemented much more efficiently from a storage and allocation perspective.

Implemented in FAnalyticsProviderLog, and FAnalyticsProviderBroadcast.

◆ SetGender()

virtual void IAnalyticsProvider::SetGender ( const FString &  InGender)
inlinevirtual

Sets the gender the game believes the user is as part of the session

◆ SetLocation()

virtual void IAnalyticsProvider::SetLocation ( const FString &  InLocation)
inlinevirtual

Sets the location the game believes the user is playing in as part of the session

◆ SetSessionID()

virtual bool IAnalyticsProvider::SetSessionID ( const FString &  InSessionID)
pure virtual

Sets the session ID of the analytics session. This is not something you normally have to do, except for circumstances where you need to send events on behalf of another user (like a dedicated server sending events for the connected clients).

Implemented in FAnalyticsProviderLog, and FAnalyticsProviderBroadcast.

◆ SetUserID()

virtual void IAnalyticsProvider::SetUserID ( const FString &  InUserID)
pure virtual

Set the UserID for use with analytics. Some providers require a unique ID to be provided when supplying events, and some providers create their own. If you are using a provider that requires you to supply the ID, use this method to set it.

Implemented in FAnalyticsProviderLog, and FAnalyticsProviderBroadcast.

◆ StartSession() [1/4]

bool IAnalyticsProvider::StartSession ( )
inline

Starts a session. It's technically legal to send events without starting a session. The use case is for backends and dedicated servers to send events on behalf of a user without technically affecting the session length of the local player. Local players log in and start/end the session, but remote players simply call SetUserID and start sending events, which is legal and analytics providers should gracefully handle this. Repeated calls to this method will be ignored.

Returns
true if the session started successfully.

◆ StartSession() [2/4]

bool IAnalyticsProvider::StartSession ( const FAnalyticsEventAttribute Attribute)
inline

Overload for StartSession that takes a single attribute

Parameters
Attributeattribute name and value

◆ StartSession() [3/4]

bool IAnalyticsProvider::StartSession ( const FString &  ParamName,
const FString &  ParamValue 
)
inline

Overload for StartSession that takes a single name/value pair

Parameters
ParamNameattribute name
ParamValueattribute value

◆ StartSession() [4/4]

virtual bool IAnalyticsProvider::StartSession ( const TArray< FAnalyticsEventAttribute > &  Attributes)
pure virtual

Starts a session. See parameterless-version for contract details.

Parameters
Attributesattributes of the session. Arbitrary set of key/value pairs that will be sent with the StartSession event that this should also trigger.

Implemented in FAnalyticsProviderLog, and FAnalyticsProviderBroadcast.


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