Add Antlytics to Spring Boot
This guide covers Spring Boot applications using Thymeleaf templates.
Prerequisites
- An Antlytics account (sign up free)
- Your tracking ID from Settings → Tracking Snippet in your Antlytics dashboard
Install the snippet
Open your layout template — typically src/main/resources/templates/layout.html (or fragments/layout.html if you use Thymeleaf layout dialect) — and paste the snippet inside <head>:
<!-- src/main/resources/templates/layout.html -->
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
th:fragment="layout(content)">
<head>
<meta charset="UTF-8" />
<title th:text="${pageTitle}">My App</title>
<script
defer
src="https://www.antlytics.com/tracker.js"
data-tracking-id="YOUR-SITE-ID"
data-api-host="https://www.antlytics.com"
></script>
</head>
<body>
<div th:replace="${content}"><!-- page content --></div>
</body>
</html>
Note: Replace
YOUR-SITE-IDwith the tracking ID from your Antlytics dashboard.
If you do not use a shared layout template, add the snippet to each page template's <head> section, or create a shared fragment:
<!-- src/main/resources/templates/fragments/analytics.html -->
<script
th:fragment="analytics"
defer
src="https://www.antlytics.com/tracker.js"
data-tracking-id="YOUR-SITE-ID"
data-api-host="https://www.antlytics.com"
></script>
Then include it with th:replace="~{fragments/analytics :: analytics}".
Verify installation
- Visit your site in a browser.
- Open your Antlytics dashboard → Overview.
- Your visit should appear within a few seconds.
If data does not appear after a few minutes, check the troubleshooting guide.
Optional: First-party proxy
To avoid ad blockers, set up a first-party proxy on your own domain.
Need help?
Email support@antlytics.com with your site ID and page URL.
Something missing? Get in touch and we will update these docs.