Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
945abdc
Update hash-based-routing reference in top-pages.md
macobo Jun 20, 2025
93b0703
Update plausible-script.md
macobo Jun 20, 2025
d9d04fd
Update custom events/custom props goals, removing snippet upgrade sec…
macobo Jun 20, 2025
734a330
Link to upgrade guide in custom properties docs
macobo Jun 20, 2025
e8f834f
Update hash-based-routing docs
macobo Jun 20, 2025
f9ea571
Update custom-event-goals.md - add more information on tracking
macobo Jun 20, 2025
6e83c1e
Mostly complete update guide
macobo Jun 25, 2025
e826fc3
Remove a now-invalid section from script-extensions.md
macobo Jun 25, 2025
4251bc1
Update integration-guides wording
macobo Jun 25, 2025
8daecf8
Update docs/custom-automatic-link-tracking.md
macobo Jun 25, 2025
bfdeaee
Update docs/file-downloads-tracking.md
macobo Jun 25, 2025
b14b326
Update docs/error-pages-tracking-404.md
macobo Jun 25, 2025
30468aa
Update docs/ecommerce-revenue-tracking.md, remove unneeded screenshot
macobo Jun 25, 2025
0886183
Update docs/webflow-integration.md
macobo Jun 25, 2025
39399b4
docs/stop-tracking-utm-tags.md via transformRequest
macobo Jun 25, 2025
df9d785
docs/file-downloads-tracking.md
macobo Jun 25, 2025
4d09981
Rewrite docs/custom-locations.md
macobo Jun 25, 2025
b3ca548
Update docs/custom-locations.md
macobo Jun 26, 2025
8cbca04
Update docs/custom-query-params.md
macobo Jun 26, 2025
efb7898
Update hash-based-routing docs
macobo Jun 26, 2025
8817df4
Remove mentions of rollup
macobo Jun 26, 2025
3541b1e
Update references
macobo Jun 26, 2025
7464969
Update references
macobo Jun 26, 2025
2f4b963
Update docs/custom-automatic-link-tracking.md code for custom link tr…
macobo Jun 30, 2025
e284039
Remove mention of delay from custom event goals
macobo Jun 30, 2025
8fcbc1a
Rewrite docs/script-extensions.md
macobo Jul 1, 2025
d22f1e9
Remove redundant instructions from docs/outbound-link-click-tracking.md
macobo Jul 1, 2025
7cdd332
Add documentation on form submissions
macobo Jul 1, 2025
bf1a3ff
Update docs/shopify-integration.md
macobo Jul 1, 2025
2f1c0e3
Update troubleshoot-integration.md
macobo Jul 1, 2025
12e3daa
Update s- -> pa-
macobo Aug 12, 2025
ad3c774
Update docs for sites API
apata Aug 11, 2025
c2e19d2
Mention NPM library in plausible-script.md
macobo Aug 18, 2025
45b5006
Enhance 404 tracking docs
macobo Aug 25, 2025
d6cd2b4
Add note on svg elements
macobo Aug 25, 2025
6278142
Rewrite apache guide
macobo Aug 28, 2025
17c499b
Updated cloudflare instructions
macobo Aug 28, 2025
2ae5c03
Update vercel guide
macobo Aug 28, 2025
ce83373
Update Caddy guide
macobo Aug 28, 2025
b279eae
Update Fresh guide
macobo Aug 28, 2025
688c75b
Fix vercel guide
macobo Aug 28, 2025
d890bed
Update Nginx guide
macobo Aug 28, 2025
d2e35e8
Deprecate some guides
macobo Aug 28, 2025
9e72430
Update proxy introduction.md
macobo Aug 28, 2025
07fc413
Update carrd guide
macobo Aug 28, 2025
95b8ff3
Rewrite GTM template guide
macobo Aug 28, 2025
f52e1b4
Add a note on google tag manager upgrade guide
macobo Aug 28, 2025
884b3aa
Update discourse guide
macobo Aug 28, 2025
6d3ae8f
Update outbound link wording
macobo Sep 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 20 additions & 94 deletions docs/carrd-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,29 @@ title: Adding Plausible to Carrd (and tracking custom events)

import useBaseUrl from '@docusaurus/useBaseUrl';

Here's how to add Plausible Analytics to your Carrd site and set up the tracking of custom events such as button clicks and form submissions.
Here's how to add Plausible Analytics to your Carrd site and set up the tracking of custom events such as button clicks.

## How to add Plausible to your Carrd website
## How to add Plausible to your Carrd website

### Enable "Hashed page paths" for your site in your Plausible account
### Get your site snippet

Carrd is a one-page website builder that doesn't support normal navigation. This means that you can enable "**Hashed page paths**" tracking as an optional measurement when adding a new site to your Plausible account. If the site has already been added to your account, you can control how data is collected in the "**Site Installation**" area of the "**General**" section in your [site settings](website-settings.md).

<img alt="Enable hashed page paths tracking during onboarding" src={useBaseUrl('img/onboarding-enable-hash-based-tracking.png')} />

Plausible tracking snippet changes depending on your selection of optional 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.
We display your snippet during the process of adding a new site to your account. You can also see the snippet within the "**Site Installation**" area of the "**General** section in your [site settings](website-settings.md).

### Go to your Carrd website editor

* Go to the editor of your Carrd website and add an "**Embed**" component.

<img alt="Add embed element to Carrd" src={useBaseUrl('img/add-embed-element-to-carrd.png')} />

* In the element's settings make sure:
* In the element's settings make sure:

- Type is set to "**Code**"
- Style is set to "**Hidden**" and "**Head**"

* Then paste your Plausible tracking script in the **Code** field

* In the snippet, update `plausible.init()` to `plausible.init({ hashBasedRouting: true })`. This allows plausible to track hashed page paths that Carrd uses during navigation.

* Do click on the "**Done**" button and then "**Publish**" your changes. After you change the tracking snippet on your site, all the hash-based page paths on your Carrd website will start being tracked and will be displayed in the "**Top Pages**" report of your Plausible Analytics dashboard.

<img alt="Add Plausible Analytics script to Carrd" src={useBaseUrl('img/add-plausible-script-to-carrd.png')} />
Expand All @@ -41,97 +39,25 @@ Now you can go to your Carrd website and verify that Plausible script has been a
As an alternative to custom events, check out [pageview goals](pageview-goals.md). Since pageviews are collected automatically, you don’t need to change your website’s code to measure pageview goals. This makes pageview goals the easiest way to start tracking any type of conversions.
:::

### 1. Enable "Custom events" for your site

You can enable "**Custom events**" as an optional measurement when adding a new site to your Plausible account. If the site has already been added to your account, you can control what data is collected in the "**Site Installation**" area of the "**General** section in your [site settings](website-settings.md).

### 2. Change the snippet on your site

The tracking snippet changes depending on your selection of optional 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. We display your snippet during the process of adding a new site to your account. You can also see the snippet within the "**Site Installation**" area of the "**General** section in your [site settings](website-settings.md).

### 3. Trigger custom events with JavaScript on your site

Here's the code you will need to insert in the `<head>` section of the page where the element ID that you want to track is located. You can use the "**Custom Code**" feature to do this similarly to how you've inserted the Plausible snippet into your site.

Make sure to change the `elementId` line in the code below to include the ID attribute of the element you want to track (`form01` in our example). In Carrd forms have default IDs. Usually they're assigned IDs based on the order you've added them. If you only have one form on the page it has an ID of "**form01**". If you're on a higher plan, like Pro Plus, you'll be able to set these IDs yourself from the element's settings.

Also do change the `classes` line to include the goal name in this format: `plausible-event-name=Goal+Name`. The goal name is completely up to you. It's the name under which the goal conversions will appear in your Plausible dashboard. We've used `Form+Submit` goal name in our example.

:::tip To represent a space character in goal names, you can use a `+` sign
For example: `plausible-event-name=Form+Submit` will display as `Form Submit` in your Plausible dashboard
:::

```html
<script>
var toTag = [
{
elementId: 'form01',
classes: 'plausible-event-name=Form+Submit'
}
]

document.addEventListener('DOMContentLoaded', function (_e) {
toTag.forEach(function (tagObject) {
var element = document.getElementById(tagObject.elementId)
tagObject.classes.split(' ').forEach(function (className) {
if (element) { element.classList.add(className) }
})
})
})
</script>
```

<img alt="Modify Plausible script Carrd for form tracking" src={useBaseUrl('img/track-form-submissions-carrd.png')} />

Now you'll have to click on the form element to select it, click on the gear icon to access the form settings and then on "**Events**" tab. Add the same script as above in the "**On Success**" event box

```html
<script>
var toTag = [
{
elementId: 'form01',
classes: 'plausible-event-name=Form+Submit'
}
]

document.addEventListener('DOMContentLoaded', function (_e) {
toTag.forEach(function (tagObject) {
var element = document.getElementById(tagObject.elementId)
tagObject.classes.split(' ').forEach(function (className) {
if (element) { element.classList.add(className) }
})
})
})
</script>
```

<img alt="On success form tracking in Carrd" src={useBaseUrl('img/track-form-submissions-submit-carrd.png')} />
You can enable form submission tracking as an optional measurement when adding a new site to your Plausible account. If the site has already been added to your account, you can control how data is collected in the "**Site Installation**" area of the "**General**" section in your [site settings](website-settings.md).

## Tracking button clicks and other links on your Carrd site

### 1. Enable "Custom events" for your site

You can enable "**Custom events**" as an optional measurement when adding a new site to your Plausible account. If the site has already been added to your account, you can control what data is collected in the "**Site Installation**" area of the "**General** section in your [site settings](website-settings.md).

### 2. Change the snippet on your site
### 1. Set an ID to the element you want to track

The tracking snippet changes depending on your selection of optional 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. We display your snippet during the process of adding a new site to your account. You can also see the snippet within the "**Site Installation**" area of the "**General** section in your [site settings](website-settings.md).
In Carrd buttons and links have default IDs. Usually they're assigned IDs based on the order you've added them. So first button or link has an ID of "**buttons01**"/"**links01**", second button or link has an ID of "**buttons02**"/"**links02**" and so on and so forth.

### 3. Set an ID to the element you want to track
If you're on a higher plan, like Pro Plus, you'll be able to set these IDs yourself from the element's settings.

In Carrd buttons and links have default IDs. Usually they're assigned IDs based on the order you've added them. So first button or link has an ID of "**buttons01**"/"**links01**", second button or link has an ID of "**buttons02**"/"**links02**" and so on and so forth.

If you're on a higher plan, like Pro Plus, you'll be able to set these IDs yourself from the element's settings.

To be sure of your element's ID, you can use your browser's dev tool to inspect the element.
To be sure of your element's ID, you can use your browser's dev tool to inspect the element.

<img alt="Confirm element ID in Carrd" src={useBaseUrl('img/confirm-element-id-carrd.png')} />

### 4. Trigger custom events with JavaScript on your site
### 2. Trigger custom events with JavaScript on your site

Here's the code you will need to insert in the `<head>` section of the page where the element ID that you want to track is located. You can use the "**Custom Code**" feature to do this similarly to how you've inserted the Plausible snippet into your site.

Make sure to change the `elementId` line in the code below to include the ID attribute of the element you want to track (`buttons01` in our example).
Make sure to change the `elementId` line in the code below to include the ID attribute of the element you want to track (`buttons01` in our example).

Also do change the `classes` line to include the goal name in this format: `plausible-event-name=Goal+Name`. The goal name is completely up to you. It's the name under which the goal conversions will appear in your Plausible dashboard. We've used `Button+Click` goal name in our example.

Expand Down Expand Up @@ -159,21 +85,21 @@ Also do change the `classes` line to include the goal name in this format: `plau

Do click on the "**Save Changes**" button and then "**Publish**" your changes.

### 5. Create a custom event goal in your Plausible account
### 3. Create a custom event goal in your Plausible account

When you send custom events to Plausible, they won't show up in your dashboard automatically. You'll have to configure the goal for the conversion numbers to show up.

To configure a goal, go to [your website's settings](website-settings.md) in your Plausible account and visit the "**Goals**" section.
To configure a goal, go to [your website's settings](website-settings.md) in your Plausible account and visit the "**Goals**" section.

Click on the "**+ Add goal**" button to go to the goal creation form. Select `Custom event` as the goal trigger and enter the name of the custom event you are triggering. The name must be an exact match to the one you added to your site for the conversions to show up in your dashboard.

So in our example where we added a goal name `plausible-event-name=Button+Click` to the Carrd site, the goal to add in the Plausible account is `Button Click` (plus is replaced by a space).

<img alt="Add your custom event goal" src={useBaseUrl('img/button-click-custom-event-goal-carrd.png')} />

Next, click on the "**Add goal**" button and you'll be taken back to the Goals page.
Next, click on the "**Add goal**" button and you'll be taken back to the Goals page.

### 6. Your goal should now be ready and tracking
### 4. Your goal should now be ready and tracking

Your goal should now be set up. When you navigate back to your Plausible Analytics dashboard, you should see the number of visitors who triggered the custom event. Goal conversions are listed at the very bottom of the dashboard. The goal will show up in your dashboard as soon as it has been completed at least once.

Expand All @@ -186,11 +112,11 @@ If you want to trigger multiple custom events on the same site, you don't need t
var toTag = [
{
elementId: 'buttons01',
classes: 'plausible-event-name=Button+Click'
classes: 'plausible-event-name=Button+Click'
},
{
elementId: 'links01',
classes: 'plausible-event-name=Link+Click'
classes: 'plausible-event-name=Link+Click'
}
]

Expand Down
46 changes: 5 additions & 41 deletions docs/custom-automatic-link-tracking.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,17 @@ If you track link clicks, then these count towards your billable monthly pagevie

Many sites use link cloaking to make affiliate links cleaner and easier to manage. So rather than linking to `affiliatepartner.com/affiliateid` you link to a page on your domain name such as `yourdomain.com/go/affiliatepartner` and the visitor gets redirected to the actual affiliate link after clicking.

The same system is used to make pretty URLs for file names. You have links to `yourdomain.com/product/download/productname` that actually redirect to `yourdomain.com/123456/Product2.3.exe`.
The same system is used to make pretty URLs for file names. You have links to `yourdomain.com/product/download/productname` that actually redirect to `yourdomain.com/123456/Product2.3.exe`.

Instructions below can be used to start tracking every `<a>` (i.e. link) element on your site with some specified rules. It's very similar to our automated tracking of [outbound link clicks](outbound-link-click-tracking.md) and [file downloads](file-downloads-tracking.md) but you can choose based on the link URL (`href` attribute) which links to track.

Here's how to automatically track clicks on cloaked affiliate links and other pretty URLs:

:::tip Our WordPress plugin can track cloaked affiliate links automatically
:::tip Our WordPress plugin can track cloaked affiliate links automatically
On WordPress? Check out our WordPress plugin which can track cloaked affiliate links automatically. [See more here](https://plausible.io/wordpress-analytics-plugin).
:::

## 1. Trigger custom events with JavaScript on your site

First, make sure your tracking setup includes the second line as shown below:

```html
<script defer data-domain="yourdomain.com" src="https://plausible.io/js/script.js"></script>
<script>window.plausible = window.plausible || function() { (window.plausible.q = window.plausible.q || []).push(arguments) }</script>
```
## 2. Add the JavaScript that will be sending the link click events to Plausible
## 1. Add the JavaScript that will be sending the link click events to Plausible

You need to add the following code to all of the pages where you want to track your links. You should insert the code below into your HTML page `<head>` section just under the custom event snippet.

Expand All @@ -43,15 +35,6 @@ On the line that says `var toBeTracked = '/go/'` change `/go/` to what you want
return link
}

function shouldFollowLink(event, link) {
// If default has been prevented by an external script, Plausible should not intercept navigation.
if (event.defaultPrevented) { return false }

var targetsCurrentWindow = !link.target || link.target.match(/^_(self|parent|top)$/i)
var isRegularClick = !(event.ctrlKey || event.metaKey || event.shiftKey) && event.type === 'click'
return targetsCurrentWindow && isRegularClick
}

var MIDDLE_MOUSE_BUTTON = 1

function handleLinkClick(event) {
Expand All @@ -62,26 +45,7 @@ On the line that says `var toBeTracked = '/go/'` change `/go/` to what you want
if (link && shouldTrackLink(link)) {
var eventName = 'Cloaked Link: Click'
var eventProps = { url: link.href }
return sendLinkClickEvent(event, link, eventName, eventProps)
}
}

function sendLinkClickEvent(event, link, eventName, eventProps) {
var followedLink = false

function followLink() {
if (!followedLink) {
followedLink = true
window.location = link.href
}
}

if (shouldFollowLink(event, link)) {
plausible(eventName, { props: eventProps, callback: followLink })
setTimeout(followLink, 5000)
event.preventDefault()
} else {
plausible(eventName, { props: eventProps })
}
}

Expand Down Expand Up @@ -109,7 +73,7 @@ If simply containing a substring is not enough to differentiate between links yo

where `\/` stands for a forward slash (escaped with `\`) and `.*` will match any (or empty) string in the middle. It will basically match anything that contains the format `products/<anything>/details`.

## 3. Create a custom event goal in your Plausible Analytics account
## 2. Create a custom event goal in your Plausible Analytics account

You'll have to configure the goal for the click numbers to show up in your Plausible dashboard. To configure a goal, go to [your website's settings](website-settings.md) in your Plausible Analytics account and visit the "**Goals**" section. You should see an empty list with a prompt to add a goal.

Expand All @@ -119,6 +83,6 @@ Click on the "**+ Add goal**" button to go to the goal creation form.

Select `Custom event` as the goal trigger and enter this exact name: `Cloaked Link: Click`.

Next, click on the "**Add goal**" button and you'll be taken back to the Goals page. When you navigate back to your Plausible Analytics dashboard, you should see the number of visitors who have completed your new custom event. Goal conversions are listed at the very bottom of the dashboard. Note that at least one click is required for this to show in your dashboard.
Next, click on the "**Add goal**" button and you'll be taken back to the Goals page. When you navigate back to your Plausible Analytics dashboard, you should see the number of visitors who have completed your new custom event. Goal conversions are listed at the very bottom of the dashboard. Note that at least one click is required for this to show in your dashboard.

That's it. You're now tracking all link clicks on your site with custom URL matching rules!
Loading