lua tracker setup - OXYGEN-MARKET/oxygen-market.github.io GitHub Wiki

HOME > SNOWPLOW SETUP GUIDE > Step 2: setup a Tracker > Lua tracker

Contents

1. Overview

The Snowplow Lua Tracker lets you add analytics to your Lua-based applications, Lua web servers/frameworks, or from the Lua scripting layer within your games or apps.

The tracker should be relatively straightforward to setup if you are familiar with Lua development.

Ready? Let's get started.

Back to top

2. Integration options

2.1 Tracker compatibility

As a lightweight, easily-embeddable scripting language, Lua is available in a huge number of different computing environments and platforms, from World of Warcraft through OpenResty to Adobe Lightroom.

To make the Snowplow Lua Tracker work out-of-the-box with as many different Lua programs as possible, we have tried to:

  1. Minimize external dependencies
  2. Provide setup instructions for the most popular Lua environments

Back to top

2.2 Dependencies

To make the Snowplow Lua Tracker work with as many different Lua programs as possible, we have tried to keep external dependencies to a minimum. There is only one external dependency currently:

  • LuaSocket - network support for the Lua language. Required to send events to the Snowplow collector

All other dependencies are bundled with the Lua Tracker itself - see the src/lib folder for details.

Back to top

2.3 Documented environments

Below we provide setup instructions for the following popular Lua environments:

  1. LuaRocks is a popular deployment and management system for Lua modules
  2. Debian/Ubuntu for developers working directly with Lua in a Linux environment
  3. Embedded environments for game, app and SDK developers working with embedded Lua

We expect that the Snowplow Lua Tracker should work in other Lua environments too - please let us know how you get on with setting it up elsewhere.

Back to top

3. Setup

3.1 LuaRocks

The Snowplow Lua Tracker is published to LuaRocks, the popular deployment and management system for Lua modules.

This makes it easy to either install the tracker locally, or to add it as a dependency into your own LuaRocks-based app.

To install the Snowplow Lua Tracker locally (assuming you already have LuaRocks installed):

$ luarocks install SnowplowTracker

To add the Snowplow Tracker as a dependency to your own LuaRocks-based app, edit your rockspec and add:

dependencies = {
  "SnowplowTracker ~> 0.1.0"
}

Done? Now read the Lua Tracker API to start tracking events.

3.2 Debian/Ubuntu

If your Lua app is running on a Linux box, you will need to install Lua and LuaSocket. On Ubuntu:

$ sudo aptitude install lua liblua5.1-socket2

On Debian:

$ sudo apt-get install lua liblua5.1-socket2

Then download the Snowplow Lua Tracker like so:

$ git clone [email protected]:snowplow/snowplow-lua-tracker.git

Copy the /src/snowplow folder into your own Lua app's library folder, something like:

$ cp -r snowplow-lua-tracker/src/snowplow my-app/lib/

Now add the Snowplow Lua Tracker into your Lua app's package.path, like so:

package.path = './lib/?.lua;' .. './lib/snowplow/?.lua;' .. package.path

Done? Now read the Lua Tracker API to start tracking events.

3.3 Embedded environments

For embedded Lua environments, you will first need to ensure that LuaSocket is available (or installable). Here are instructions for adding LuaSocket into some popular games, SDKs and other apps which use Lua:

Game/app/SDK LuaSocket bundled? Installation instructions
cocos2d-x No Installation instructions
Garry's Mod No Port of LuaSocket for GMod
Cheat Engine No Installation instructions
Girder Yes (ref) Enable the plugin from Girder Settings
Corona SDK Yes (ref) -
LÖVE Yes (ref) -
Moai Yes (ref) -
World of Warcraft Yes (ref) -

LuaSocket taken care of? Next, download the Snowplow Lua Tracker like so:

$ git clone [email protected]:snowplow/snowplow-lua-tracker.git

Now copy the /src/snowplow folder into the folder for your Lua scripts, perhaps something like:

$ cp -r snowplow-lua-tracker/src/snowplow my-app/lua-scripts/lib/

Now add the Snowplow Lua Tracker into your Lua app's package.path, like so:

package.path = './lib/?.lua;' .. './lib/snowplow/?.lua;' .. package.path

That's it! Now read the Lua Tracker API to start tracking events.

⚠️ **GitHub.com Fallback** ⚠️