Docusaurus
After you sign up on Swetrix and create a new project, the only thing left is to add it to your website.
Installation
- Open your Docusaurus project.
- Edit the
docusaurus.config.js
file and add the following insidemodule.exports
:
module.export = {
...
scripts: [
{ src: 'https://swetrix.org/swetrix.js', defer: true },
{ src: 'js/setupswetrix.js', defer: true }
],
...
}
- Create a new file at
static/js/setupswetrix.js
and add the following:
document.addEventListener('DOMContentLoaded', function () {
swetrix.init('YOUR_PROJECT_ID')
swetrix.trackViews()
})
caution
It's very important not to forget to replace YOUR_PROJECT_ID
with your actual Project ID you can find in the Dashboard, otherwise tracking won't work!
Check your installation
After installing Swetrix tracking script, go to your website and visit some pages.
Within a minute you should be able to see new pageviews being added to your project's dahsboard.