Installing the script — customer guide
Astrelia Analytics installs with a single line. It sets no cookies and stores nothing on visitors' devices, so no consent banner is required.
1. The snippet
Paste this line into every page, before </head> (or before </body>; either
works). Replace XXXXXXXX with your site id, shown in the dashboard under
Settings → Snippet.
<script defer src="https://analytics.astrelia.it/js/a.js" data-site="XXXXXXXX"></script>
The script is under 2 KB, loads deferred and never slows the page down. Within a minute of the first visit the dashboard reports "script installed".
Platforms
| Platform | Where to paste it |
|---|---|
| WordPress | Appearance → Theme editor → header.php, or a plugin such as WPCode (Header) |
| PrestaShop | Design → Themes → Edit theme → head.tpl, or the Custom code module |
| Shopify | Themes → Edit code → theme.liquid, before </head> |
| Joomla | System → Templates → index.php |
| Static HTML / other CMS | the template shared by all pages |
| Google Tag Manager | a Custom HTML tag with the snippet, trigger All Pages |
2. Options (all optional)
Set as attributes on the same <script> tag:
| Attribute | Effect |
|---|---|
data-domain="www.mysite.com" |
force the registered domain when the site also answers on other hosts |
data-hash="1" |
treat # changes as separate pages (single-page apps with hash routing) |
data-exclude="/admin/*,/preview" |
paths to ignore (* matches anything) |
data-outbound="0" |
disable automatic outbound-link click events |
data-downloads="0" |
disable automatic download events (pdf, zip, doc…) |
data-forms="0" |
disable automatic form-submit events |
data-dnt="0" |
ignore Do Not Track and Global Privacy Control (respected by default) |
data-api="https://stats.mysite.com/api/event" |
alternative endpoint, see §4 |
3. Custom events and goals
From JavaScript:
window.aa('newsletter-signup');
window.aa('purchase', { product: 'Shoes', amount: '79' });
Calls made before the script has loaded do not throw. To keep events fired before load, add this line before the snippet:
<script>window.aa=window.aa||function(){(window.aa.q=window.aa.q||[]).push(arguments)}</script>
From HTML, with no JavaScript:
<a href="/contact" data-aa-event="cta-contact" data-aa-prop-position="header">Contact us</a>
An event carries at most 10 properties of up to 100 characters each. In the
dashboard any event — or any page, e.g. /thank-you — can become a goal with a
conversion rate.
Automatically collected events: outbound (external link click), download,
form (form submission).
4. Serving the script from your own domain (ad-blocker proof)
Some blockers filter third-party analytics scripts. Serving the script and the endpoint from a subdomain of your site keeps everything first-party.
Plesk / nginx — create stats.mysite.com and add under Apache & nginx
Settings → Additional nginx directives:
location = /js/a.js {
proxy_pass https://analytics.astrelia.it/js/a.js;
proxy_set_header Host analytics.astrelia.it;
proxy_ssl_server_name on;
expires 1d;
}
location = /api/event {
proxy_pass https://analytics.astrelia.it/api/event;
proxy_set_header Host analytics.astrelia.it;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_ssl_server_name on;
}
Apache (.htaccess or vhost, mod_proxy enabled):
SSLProxyEngine On
ProxyPass "/js/a.js" "https://analytics.astrelia.it/js/a.js"
ProxyPass "/api/event" "https://analytics.astrelia.it/api/event"
ProxyPreserveHost Off
RequestHeader set X-Forwarded-For "%{REMOTE_ADDR}s"
No access to server configuration — a stats.php file:
<?php
// Minimal proxy: forwards the request body and the visitor's IP.
$ch = curl_init('https://analytics.astrelia.it/api/event');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => file_get_contents('php://input'),
CURLOPT_HTTPHEADER => [
'Content-Type: text/plain',
'User-Agent: '.($_SERVER['HTTP_USER_AGENT'] ?? ''),
'X-Forwarded-For: '.$_SERVER['REMOTE_ADDR'],
],
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 3,
]);
curl_exec($ch);
http_response_code(204);
Then set data-api="https://www.mysite.com/stats.php" in the snippet. For the
visitor's IP to be forwarded, tell us your server's IP so we can add it to the
trusted proxies. (The IP is only used for the country and the daily hash; it is
never stored.)
5. Checking it works
- Open your site, then the dashboard: your visit shows up in Realtime within a minute.
- In DevTools → Network the request to
/api/eventreturns204with noSet-Cookieheader; Application → Storage stays empty. - To exclude your own visits, run
localStorage.setItem('aa_ignore', '1')in the browser console (the only, voluntary, use of storage).
6. Privacy policy wording
Ready-made wording, in Italian and English, is on the Privacy and GDPR page. No change to your cookie banner is needed; if the site uses no other tracking tools, the banner can be removed altogether.