googleAnalytics.logEvent()

Type Function
Return value none
Revision Release 2024.3703
Keywords analytics, Google Analytics, googleAnalytics, logEvent
See also googleAnalytics.init()
googleAnalytics.logScreenName()
googleAnalytics.*

Overview

Logs an event with Google Analytics.

Syntax

googleAnalytics.logEvent( category, action [, label] [, value] )
category (required)

String. String which identifies the group of objects to track, for example "userAction".

action (required)

String. A string which is uniquely paired with the category and is commonly used to define the type of user interaction, for instance "button press".

label (optional)

String. An optional string which provides additional dimensions to the event data, for example "menu" or "quit".

value (optional)

Number. An optional integer which specifies the event value. Values must be non-negative.

Example

local googleAnalytics = require( "plugin.googleAnalytics" )

-- Initialize Google Analytics
googleAnalytics.init( "CoronaApp1", "UA-12345678-90" )

-- Log event with Google Analytics
googleAnalytics.logEvent( "userAction", "button press", "menuItem", 2 )