Skip to main content

For AI agents: a Markdown version of this page is at https://docs.snowplow.io/docs/sources/lua-tracker.md. The index of all documentation pages is at https://docs.snowplow.io/llms.txt, and the index for this section is at https://docs.snowplow.io/docs/cdi/llms.txt.

Lua tracker SDK

Actively maintained

Feature support Compare trackers

  • Supported: Page or screen views (Screen)
  • Not supported: Activity tracking
  • Not supported: Built-in entities
  • Not supported: Anonymous tracking
  • Not supported: Media
  • Not supported: Ecommerce
  • Not supported: Consent
  • Not supported: Snowtype

The Snowplow Lua Tracker allows you to track Snowplow events in your Lua applications.

The current version is 0.2.0. It is compatible with Lua >= 5.1, along with LuaJIT.

This will help you set up the Lua tracker and get started tracking. For more technical details, you can visit the API docs.

Getting Started​

Requirements​

Ensure you have the following installed on your system:

  • Lua version >= 5.1
  • LuaRocks (Lua's dependency manager)
  • curl

If using brew, simply run:

bash
brew install lua luarocks curl

Installation​

Once these are installed, you can install the tracker using LuaRocks:

bash
luarocks install snowplowtracker

Note: You may find that you need to pass in the CURL_DIR flag if Lua cannot find curl by itself. Below is an example if curl was installed using brew on an Intel Mac.

bash
luarocks install snowplowtracker CURL_DIR=/usr/local/Cellar/curl/7.82.0/

Or, add the Snowplow Tracker to the dependencies section of your rockspec (Note: you may still have to pass CURL_DIR when installing):

gradle
dependencies = {
...
"SnowplowTracker"
}

Tracking Events​

To track an event, simply create a tracker instance and call one of the track_* methods. For example, simple tracking of a structured event can be done as follows:

lua
local snowplow = require("snowplow")
local tracker = snowplow.new_tracker("{{ collector_url }}")

tracker:track_struct_event("category", "action", "label", "property", 10)

Visit documentation about tracking events to learn about other supported event types.

Was this page helpful?