Tracking script options
Turn link clicks, downloads, scroll depth, and hash routes on or off.
The tracking script works with no options. To change what it
records, add data- attributes to the script tag. For
example, this script also records scroll depth and does not record
the pages under /admin/:
<script defer src="https://dodolytics.com/tracker.js" data-website-id="site_xxxxxxxxxxxxxxxx" data-scroll="true" data-exclude="/admin/*"></script>
All options
| Option | Default | What it does |
|---|---|---|
data-outbound="false" | On | Stops the record of clicks on links to other websites. |
data-downloads="false" | On | Stops the record of clicks on links to files. |
data-scroll="true" | Off | Records how far visitors scroll on each page. |
data-hash="true" | Off | Records each page of an app with hash routing, for example /#/pricing. |
data-exclude="..." | None | Sends nothing from the paths that you list. |
data-api="..." | The script's own server | The address that the script sends to. Use it only with a proxy on your domain. |
data-allow-localhost="true" | Off | Counts visits on localhost, for a test on your own computer. |
Outbound links and file downloads
The script records a click on a link to another website as an
outbound_click event. It records a click on a link to a
file as a file_download event. Both show on the
Pages report, on the
Outbound links and File downloads
tabs.
- The address of the link is recorded without the part after
?or#. - A link to
www.of your own domain is not an outbound link. - A link is a file when its address ends in a file type such as
.pdf,.zip,.dmg,.exe,.csv,.docx,.xlsx, or.mp4, or when the link has adownloadattribute. A file on another website counts as a download, not as an outbound link. - A click with the middle mouse button (to open a new tab) counts too.
Scroll depth
With data-scroll="true", the script sends a
scroll_depth event the first time a visitor reaches 25,
50, 75, and 100 percent of a page. The depth property
holds the number. Open the event on the Events tab of
Goals. Under Event
properties, the count of each depth is the number of page
views that reached it.
Only a real scroll counts. A short page that fits on the screen sends no scroll depth event.
Hash routing
Some apps keep the page in the part after #, for example
/#/pricing. With data-hash="true", each of
these pages is a page in your reports. Only a hash that starts with
#/ or #!/ is recorded. Other hashes, for
example an anchor such as #features, are never sent.
Exclude paths
List the paths that the script must not record, with a comma between
them. A * matches any characters:
data-exclude="/admin/*, /preview, /account/*"
/admin/*matches/admin/usersand/admin/, but not/admin./previewmatches only/preview.
On an excluded path, the script sends nothing: no pageview, no
events, and no analytics.identify(). To exclude people,
not paths, see Exclude your own visits.
Related articles
Still need help? Ask on our feedback board or see all topics.