Collect without JavaScript
Normally you would collect page view via our open source JavaScript. But there are other way to collect those. You can either send data via your own server or send it through a pixel (a small GIF image).
By default we already include a pixel (image) with our
<noscript>
tag. This tag gets executed when a visitor disabled JavaScript in their browser. The pixel inside the tag will still record that page view. The data connected to that page view is limited, but still useful for the overal picture.
To collect page views with our pixel you can add parameters to the URL of the image:
<img
src="https://queue.simpleanalyticscdn.com/noscript.gif?timezone=Europe%2FAmsterdam&unique=false"
referrerpolicy="no-referrer-when-downgrade"
alt=""
/>
In the example above we send a time zone and unique boolean with the pixel.
By default it will take the referrer of the pixel. This is the URL for the page the pixel is displayed on. It is not the referrer of the page, that is inaccessible from the pixel.
We automatically fetch this information via the referrer if you don’t provide anything as pixel parameters: *
hostname
(for exampleexample.com
)https
(booleantrue
if protocol of the website is https)path
(path including the/
)ua
(user agent)utm_source
utm_medium
utm_campaign
utm_content
utm_term
You can overwrite those via the pixel parameters.
These are the values we can’t get with the pixel alone:
- timezone (a valid JS time zone)
- referrer (the document.referrer of the page)
- unique (if a visit is unique; true or false)
- collect-dnt (boolean to tell if it should collect DNT visits)
* We advice to always include the
hostname
andpath
parameters if possible. Some times the browser does not send a referrer with the image and then we can’t store a page view.
This way you are more in control what you are sending to our servers. It’s also a great way if you need to avoid JavaScript for example within Google AMP environments.
We don’t record visitors that have DNT enabled. If you want to record those visits add
collect-dnt=true
to the pixel parameters.
Browser extensions
Browser extensions usually don’t have a normal URL and no referrer information. That’s why you need to specify both hostname
and path
.
<img
src="https://queue.simpleanalyticscdn.com/noscript.gif?hostname=example.com&path=%2F"
referrerpolicy="no-referrer-when-downgrade"
alt=""
/>
In most cases you can just make up a hostname
, like extension.mywebsite.com
. As long as you add it in your dashboard, it’s fine.
Validate your implementation
If you want to validate your implementation you can test this in your browser. Open the page you implemented the pixel on.
- Right click with your mouse somewhere on the page
- Click “inspect” or sometimes “inspect element” in the menu that pops up
- Click the “network” tab
- Search for a request that ends with “noscript.gif”
- In the sidebar you will see the headers of that request. Look for the “simple-analytics-feedback” header and check the value. It should say something like: “Thanks for sending this page view!”