If you’re looking for an open-source, self-hostable analytics solution that integrates seamlessly with modern frameworks, look no further! Litlyx allows you to track key performance indicators (KPIs) effortlessly and offers a developer-friendly experience. In this guide, we’ll walk you through the steps to get started with Litlyx, connecting it to your website, and self-hosting it effectively.
Pre-Requisites for Using Litlyx
- Sign up on Litlyx.com and create a project.
- Gather your project ID to connect Litlyx to your website.
- Optionally, self-host Litlyx with Docker.
Universal Installation
Setting up Litlyx has never been easier—just follow these quick steps:
<script defer data-project="project_id_here" src="https://cdn.jsdelivr.net/gh/litlyx/litlyx-js/browser/litlyx.js"></script>
By importing Litlyx using the above script, you instantly start tracking 10 KPIs, including:
- Page Visits
- Browsers
- Devices
- Operating Systems
- Real-Time Online Users
- Unique Sessions
- Countries
- Average Session Time
Installing Litlyx in Different Environments
You can install Litlyx using your JavaScript package manager of choice:
npm i litlyx-js
Litlyx is compatible with all JavaScript and TypeScript frameworks, making it versatile for various projects. You can also inject the JS code into your WordPress websites via a plugin and utilize it in serverless environments through Cloud (or Edge) Functions.
Importing and Initializing Litlyx
Let’s dive into the code:
import Lit from 'litlyx-js';
Lit.init(your_project_id);
Think of this setup process like setting up a smart home system. The importing acts as the initial setup, and the initialization is like configuring your smart device to connect to your home’s Wi-Fi network. Once this is done, Litlyx begins automatically tracking various analytics for you.
Tracking Custom Events
Litlyx allows you to go beyond the built-in KPIs and track events specific to your project:
Lit.event('click_on_buy_item');
For more detailed tracking, include metadata:
Lit.event('click_on_buy_item', { metadata: { product-name: 'Coca-Cola', price: 1.50 } });
This flexibility is like having a customizable alarm system where you can add various sensors for specific areas of your home, ensuring you keep an eye on what matters most.
Firing Your First Event with cURL
If you want to test how Litlyx interacts with events, you can quickly send a test event with the following cURL command:
curl -X POST https://broker.litlyx.com/event -H "Content-Type: application/json" -d '{ "pid": "project_id", "name": "testEvent1", "metadata": { "test": "something", "website": "something", "userAgent": "something" } }'
Self-Hosting Litlyx with Docker
The self-hosting process is straightforward:
- Fork the Litlyx repository.
- Run the following command:
- After the build finishes, run:
docker-compose build
docker-compose up
Now you can access your own instance of the Litlyx Dashboard at localhost:3000.
Official Documentation and Community Support
For more information, check out the documentation, where you’ll find comprehensive guides to enhance your experience. If you have any questions or need support, feel free to join our community on Discord.
Troubleshooting Tips
- If Litlyx doesn’t seem to be tracking data, double-check that your project ID is correct in the initialization step.
- Ensure that the Litlyx script is properly loaded in your HTML and functions as intended without errors.
- If events aren’t firing, ensure that you’re pointing to the right API endpoint and that your metadata is formatted correctly.
For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.
Conclusion
At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.