GamaSalad & PHP & Amplitude

Posted by

I have been using Amplitude with my GameSalad app. It is easy to set up and provides valuable information about what your users are doing in your app. On top of all this Amplitude has a free tier to let you get started.

  1. Create an amplitude account.
  2. Now you need a place to host your PHP file. I host mine in my WordPress site.
  3. Create a new php file. I am using WP File Manager plugin but I believe any file manager will do. I placed the file in the root folder and named it analytics.php.

4. Copy and past the content of this php script into the file.

5. Before we go to GameSalad let me explain how the URL will work. The base URL in my case will always look like this:

After that you will need to add required fields. In no particular order:

api_key: This api_key is provided when you create the app in Amplitude.

event_type: This is your event name. It could be basically anything. I have used “appLaunch”, “gameStarted”, and “leaderboardShown”. You get the idea. Special characters and spaces will probably not work with the current code.

user_id or/and device_id: In my games I generate the user_id from GameSparks and I send that as both device_id or user_id. But you only need to provide one.

Following the simple rules all these are valid urls:


6. There are also some other fields that the script supports.

os_version: I map this one inside of GameSalad to devices.platform.version

language: Mapped to devices.platform.language

country: Mapped to devices.plaform.region

device_model: Mapped to devices.platform.deviceModel

os_name: I don’t currently use it but you could map it to a property or hard code it.

app_version: I don’t use it but you could map it to a property or hard code it.

7. Finally on the GameSalad side the only pre-work I have to do is create a blank table.

I then concatenate the base URL with whatever values I want in a variable:

And then send it along using the “Get Table From URL”:

8. Here are some examples of what they look like on the other side:

And graphs like these (I made these but you can slice your data any which way you want):

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.