googleAnalytics.logEvent()

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

Overview

Logs an event with Google Analytics.

Syntax

googleAnalytics.logEvent( eventName, parameters )
eventName (required)

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

parameters (required)

Table. A table of key value pairs that are added to event, for example "{imageType = "png", id=321}".

Syntax (Legacy)

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

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

action (required)

String. A string which is uniquely paired with the event as a parameter "button_press".

label (optional)

String. An optional string which is uniquely paired with the event as a parameter "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()

-- Log event with Google Analytics
googleAnalytics.logEvent( "share_image", {imageType = "png", id=321} )

-- Legacy Log event with Google Analytics
googleAnalytics.logEvent( "user_action", "button_press", "menu_item", 2 )