sol-tracker
v1.1.0
Published
Transfer data to Tracker
Downloads
5
Maintainers
Readme
🚀 Installation
We recommend loading sol-tracker from your Tracker instance. This ensures that the script is always in sync with your installation. The script is served as tracker.js
or as a name of your choice.
<script async src="https://sol.example.com/tracker.js" data-sol-server="https://sol.example.com" data-sol-domain-id="hd11f820-68a1-11e6-8047-79c0c2d9bce0"></script>
It's also possible to install sol-tracker as a module via npm or yarn.
npm install sol-tracker
yarn add sol-tracker
🤗 Usage
| Type | Usage | Best for | Records (Views) | Actions (Events) | | :------------------------------ | :---------------------- | :---------------------------- | :-------------- | :--------------- | | Automatically | Via script tag | Simple sites | ✅ | ⛔️ | | Manually | Via script tag and code | Advanced sites | ✅ | ✅ | | Programmatic | Via module | Modern sites with build tools | ✅ | ✅ |
Automatically
The easiest way to send data to your Tracker server is by including the script along with the required attributes. Tracker will now track each page visit automatically.
This approach is perfect for static sites. It tracks a visit whenever a user visits the site or navigates to a new page. Websites with client-side routing however should consider to use any of the other approaches as this one would only track the initial page.
<script async src="dist/sol-tracker.min.js" data-sol-server="https://sol.example.com" data-sol-domain-id="hd11f820-68a1-11e6-8047-79c0c2d9bce0"></script>
It's also possible to customize Tracker using the data-sol-opts
attribute.
<script async src="dist/sol-tracker.min.js" data-sol-server="https://sol.example.com" data-sol-domain-id="hd11f820-68a1-11e6-8047-79c0c2d9bce0" data-sol-opts='{ "ignoreLocalhost": true }'></script>
Manually
Include the JS-file at the end of your body
and start tracking page visits by calling create
manually.
This approach is perfect for sites without a build system. It gives you more control than the automatic solution, but still allows you to use sol-tracker without a package manager or JS bundler.
<script src="dist/sol-tracker.min.js"></script>
<script>
solTracker.create('https://sol.example.com').record('hd11f820-68a1-11e6-8047-79c0c2d9bce0')
</script>