Quickstart
This guide shows how to send your first analytics event directly to the devgrowthlab API.
There’s no SDK or tracking script - just one simple HTTPS POST request.
Each day the user opens your app or website, send an event to the devgrowthlab service. You don’t need to send more than one event a day.
1. Get your API key
Section titled “1. Get your API key”In your dashboard, go to Settings → Integration and copy your JWT token (it should start with ey...).
You’ll use this in the Authorization header as Bearer YOUR_TOKEN.
2. Understand the request format
Section titled “2. Understand the request format”The endpoint is:
POST https://api.devgrowthlab.com/ingestRequest body:
{ "lastToken": "string or null", "cohorts": { "Example Cohort": "Example Value" }}lastToken: pass the token returned by the previous request, ornullif it’s the user’s first session.cohorts: a simple map of strings to strings - you can use it to group users by plan, referrer, or experiment.
We’ll cover advanced cohorting later in the Guides section.
Response:
{ "token": "string"}You must store this new token securely and include it as lastToken in the next request.
This token isn’t an identifier and doesn’t identify the user, its a compact representation of the last data sent
so the devgrowthlab service doesn’t duplicate records, or count the user as a fresh install on
every app open.
3. Send your first event
Section titled “3. Send your first event”Choose your preferred framework below and copy the example into your project.
const response = await fetch("https://api.devgrowthlab.com/ingest", { method: "POST", headers: { "Authorization": "Bearer YOUR_JWT_TOKEN", "Content-Type": "application/json" }, body: JSON.stringify({ lastToken: localStorage.getItem("devgrowthlab_token") || null, cohorts: { // See the guide on cohorts for more info "Example Cohort": "Example Value" } })});
const data = await response.json();if (data.token) { // ⚠️ Store the new token securely // Note: In GDPR regions, only store persistent data after user consent. localStorage.setItem("devgrowthlab_token", data.token);}import Foundation
let url = URL(string: "https://api.devgrowthlab.com/ingest")!var request = URLRequest(url: url)request.httpMethod = "POST"request.setValue("Bearer YOUR_JWT_TOKEN", forHTTPHeaderField: "Authorization")request.setValue("application/json", forHTTPHeaderField: "Content-Type")
let lastToken = UserDefaults.standard.string(forKey: "devgrowthlab_token")let payload: [String: Any?] = [ "lastToken": lastToken, "cohorts": [ "Example Cohort": "Example Value" ]]
request.httpBody = try? JSONSerialization.data(withJSONObject: payload.compactMapValues { $0 })
URLSession.shared.dataTask(with: request) { data, _, error inguard let data = data, error == nil else { return }if let json = try? JSONSerialization.jsonObject(with: data) as? [String: Any], let token = json["token"] as? String { UserDefaults.standard.set(token, forKey: "devgrowthlab_token")}}.resume()import retrofit2.Callimport retrofit2.http.Bodyimport retrofit2.http.Headerimport retrofit2.http.POST
data class IngestRequest( val lastToken: String?, val cohorts: Map<String, String>)
data class IngestResponse(val token: String)
interface DevgrowthlabApi {@POST("api/ingest") fun ingest( @Header("Authorization") auth: String, @Body body: IngestRequest ): Call<IngestResponse>}
// Usageval prefs = context.getSharedPreferences("devgrowthlab", Context.MODE_PRIVATE)val lastToken = prefs.getString("token", null)
val request = IngestRequest( lastToken, mapOf( // See the guide on cohorts for more info "Example Cohort" to "Example Value" ))
val api = Retrofit.Builder() .baseUrl("https://devgrowthlab.com/") .build() .create(DevgrowthlabApi::class.java)
api.ingest("Bearer YOUR_JWT_TOKEN", request).enqueue(object: Callback<IngestResponse> { override fun onResponse(call: Call<IngestResponse>, response: Response<IngestResponse>) { response.body()?.token?.let { prefs.edit().putString("token", it).apply() } } override fun onFailure(call: Call<IngestResponse>, t: Throwable) { t.printStackTrace() }})import okhttp3.*;
OkHttpClient client = new OkHttpClient();MediaType JSON = MediaType.parse("application/json; charset=utf-8");
String lastToken = preferences.getString("devgrowthlab_token", null);String json = "{\"lastToken\":" + (lastToken == null ? "null" : "\""+lastToken+"\"") + ",\"cohorts\":{\"Example Cohort\":\"Example Value\"}}";
RequestBody body = RequestBody.create(json, JSON);Request request = new Request.Builder() .url("https://api.devgrowthlab.com/ingest") .addHeader("Authorization", "Bearer YOUR_JWT_TOKEN") .post(body) .build();
client.newCall(request).enqueue(new Callback() { public void onResponse(Call call, Response response) throws IOException { String resp = response.body().string(); JSONObject obj = new JSONObject(resp); String token = obj.getString("token"); preferences.edit().putString("devgrowthlab_token", token).apply(); }
public void onFailure(Call call, IOException e) { e.printStackTrace(); }});import 'package:http/http.dart' as http;import 'dart:convert';import 'package:shared_preferences/shared_preferences.dart';
Future void> sendEvent() async { final prefs = await SharedPreferences.getInstance(); final lastToken = prefs.getString("growthlab_token");
final response = await http.post( Uri.parse("https://api.devgrowthlab.com/ingest"), headers: { "Authorization": "Bearer YOUR_JWT_TOKEN", "Content-Type": "application/json" }, body: jsonEncode({ "lastToken": lastToken, "cohorts": {"Example Cohort": "Example Value"} }), );
if (response.statusCode == 200) { final body = jsonDecode(response.body); await prefs.setString("growthlab_token", body["token"]); } else { print("Failed: ${response.statusCode}"); }}4. Verify your data
Section titled “4. Verify your data”Go back to your dashboard, under Settings → Integration last ingestion should now list the current date. It may take a few moments to process.
5. Optional: Setup your existing app
Section titled “5. Optional: Setup your existing app”If you have an existing app with a large cohort of existing users then it’s recommended to send additional information to the service at first so the devgrowthlab can accurately model the retention curve for your app. Follow the guide here.