We achieve that by radically limiting the number of options in the default script. Instead, we offer enhanced measurements as optional script extensions tailored to how you want to use Plausible. This approach makes sure that you only load the code that will actually be used on your website.
You can enable these optional measurements when adding a new site to your Plausible account or in the "Site Installation" area of the "General" section in your site settings.
The snippet changes depending on your selection of measurements
Note that the tracking snippet that you need to insert into your site changes depending on your selection of enhanced measurements. When making changes to your optional measurements, do ensure to insert the newest snippet into your site for all tracking to work as expected
Automatically track page paths that use a # in the URL (hash-based routing)
Custom events
Allows you to track custom events such as link clicks, form submits and any other HTML element clicks
Custom properties
Allows you to attach custom properties (also known as custom dimensions in Google Analytics) when sending a pageview or custom event to create custom metrics
Ecommerce revenue
Allows you to assign dynamic monetary values to custom events and track revenue attribution
In addition to the above list (script.outbound-links.js, script.file-downloads.js, script.hash.js, script.tagged-events.js, script.pageview-props.js and script.revenue.js), we also have some more advanced tracking options available. Note that these are not included in the site onboarding list so you will need to insert them into your tracking snippet manually.
For example, the default script name in our snippet is script.js. If your website is on a localhost and you'd like to track those visits, you have the option of loading the script with a different extension: script.local.js.
In this case, the snippet you need to insert into your site is as follows (make sure to change the data-domain attribute to the domain you added to Plausible):
You can mix and match, and combine these extensions any way that you wish. For instance, if you want to use both our hash-based routing and our outbound link click tracking, you can combine them as follows: script.hash.outbound-links.js.
In this case, the snippet you need to insert into your site is as follows (make sure to change the data-domain attribute to the domain you added to Plausible):
Or say you want to use our script.revenue.js extension to track ecommerce revenue and our script.local.js extension to track localhost traffic, your snippet should look like this:
The default Plausible script won't work on Internet Explorer because it uses the document.currentScript API to read configuration options. You can run Plausible in compatibility mode by including the script.compat.js extension and defining id="plausible" on the script tag so that it can find itself. Note that this works only on ≥ IE11. Here's how it should look like:
By default, the Plausible script triggers a pageview when it's first loaded. It also attaches listeners to the History API and will automatically trigger pageviews when you use history.pushState. This is useful for most websites but we also offer a manual mode in case you want full control over when pageviews are triggered on your website.
One of the use-cases for this is when you use Turbo (formerly Turbolinks). In that case, you want to manually trigger Plausible pageviews on the turbo:load or turbolinks:load browser event depending which library you use. Here's how you can do that:
<scriptdeferdata-domain="yourdomain.com"src="https://plausible.io/js/script.manual.js"></script> <!-- define the `plausible` function to manually trigger events --> <script>window.plausible=window.plausible||function(){(window.plausible.q=window.plausible.q||[]).push(arguments)}</script> <!-- trigger pageviews on turbolinks navigation --> <script> document.addEventListener("turbo:load",function(){ plausible('pageview') }) </script>
When using turbolinks, you should make sure that the Plausible script isn't loaded and executed during turbo navigation. You may need to move the script to the <head> section of your website or use the data-turbo-eval="false" attribute to do so.
note
When using manual.js every script call with 'pageview' results in a separate pageview being counted even if called on the same page
Additionally, the manual script extension allows you to provide a special option named u with your events. This allows you to specify the URL of the page and can be used to specify custom locations.
Track custom query parameters for complete page URLs
By default, Plausible strips all query parameters for privacy purposes except forref, source, utm_source, utm_medium, utm_campaign, utm_content and utm_term.
This means that pages like yoursite.com/blog/index.php?article=some_article&page=11 will be reported as yoursite.com/blog/index.php in the "Top Pages" report of your Plausible dashboard.
By using the manual script extension, you can also track custom query parameters and get the complete page URLs in your "Top Pages" report. Learn here how to do that.
Want to track outbound link clicks or file downloads cloaked with pretty URLs?