Desktop, mobile and extensions
Add Loogika to Tauri
You add Loogika to a Tauri v2 app in two places. The script tag goes into the head of the index.html that your frontend uses, and src-tauri/tauri.conf.json must allow https://app.loogika.com under app.security.csp. Built apps send data on Windows and Android. On macOS, Linux and iOS the webview blocks the tracking requests of a built app, as explained below.
Last updated .
What do you need before you start?
Copy your script tag from Site Settings in Loogika, under the Tracking Script tab. It looks like this, with your own site ID in place of YOUR_SITE_ID:
<script src="https://app.loogika.com/api/script.js?siteId=YOUR_SITE_ID" defer></script>
Loogika has no npm package to bundle into the app, so the script tag is the install method. Loading remote scripts goes against the advice in the security guide of Tauri. Weigh that advice before you add a tag that loads from app.loogika.com.
How do you add Loogika to a Tauri app?
The install has two steps: add the tag and allow the Loogika host in the Content Security Policy (CSP). A CSP is the list of sources a page may load code from and send data to.
- Open the
index.htmlof your frontend and paste the tag into its head. - Add
https://app.loogika.comto bothscript-srcandconnect-srcinsrc-tauri/tauri.conf.json.
{
"app": {
"security": {
"csp": {
"default-src": "'self'",
"script-src": ["'self'", "https://app.loogika.com"],
"connect-src": ["ipc:", "http://ipc.localhost", "https://app.loogika.com"]
}
}
}
}
Keep ipc: and http://ipc.localhost in connect-src. Tauri needs both for calls from the frontend to your Rust code.
If app.security.csp is not set, Tauri applies no CSP and you can skip the second step. You write the setting as a single policy string or as an object like the one above, and the two forms must not be mixed.
On which platforms does Loogika work in a built Tauri app?
Loogika works where Tauri serves the frontend from an http or https origin. The Loogika tracking endpoints answer cross-origin checks (CORS) only for origins that start with http:// or https://, and the webview blocks requests from other origins.
| Where the app runs | Origin of the frontend | Does tracking work? |
|---|---|---|
tauri dev on any platform | Your dev server, which uses http://localhost:1420 unless you change it | Yes |
| Built app on Windows and Android | http://tauri.localhost | Yes |
| Built app on macOS, Linux and iOS | tauri://localhost | No. The webview blocks the requests |
On Windows and Android you can set useHttpsScheme to true for a window under app.windows. The origin then becomes https://tauri.localhost, and tracking works with both forms.
A working tauri dev session therefore proves nothing about a macOS, Linux or iOS build. Test the built app on each platform you ship.
Does Loogika track navigation inside the app?
Yes. Loogika records a pageview when your router changes the address through the History API or through a hash route. The setting for that is SPA Navigation in Site Settings, which is on for a new site.
How do you check that Loogika is installed?
Build the app, open a few views and look at the Loogika dashboard. The pageviews show up within a few seconds on a platform where tracking works.
If nothing arrives, open the webview console. A CSP violation names the directive that blocked the request, and you add https://app.loogika.com to that directive. A CORS error on macOS, Linux or iOS is the origin limit described above.