You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
7
+
Here's how to add Plausible Analytics to your Carrd site and set up the tracking of custom events such as button clicks.
8
8
9
-
## How to add Plausible to your Carrd website
9
+
## How to add Plausible to your Carrd website
10
10
11
-
### Enable "Hashed page paths" for your site in your Plausible account
11
+
### Get your site snippet
12
12
13
-
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).
14
-
15
-
<img alt="Enable hashed page paths tracking during onboarding" src={useBaseUrl('img/onboarding-enable-hash-based-tracking.png')} />
16
-
17
-
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.
13
+
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).
18
14
19
15
### Go to your Carrd website editor
20
16
21
17
* Go to the editor of your Carrd website and add an "**Embed**" component.
22
18
23
19
<img alt="Add embed element to Carrd" src={useBaseUrl('img/add-embed-element-to-carrd.png')} />
24
20
25
-
* In the element's settings make sure:
21
+
* In the element's settings make sure:
26
22
27
23
- Type is set to "**Code**"
28
24
- Style is set to "**Hidden**" and "**Head**"
29
25
30
26
* Then paste your Plausible tracking script in the **Code** field
31
27
28
+
* In the snippet, update `plausible.init()` to `plausible.init({ hashBasedRouting: true })`. This allows plausible to track hashed page paths that Carrd uses during navigation.
29
+
32
30
* 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.
33
31
34
32
<img alt="Add Plausible Analytics script to Carrd" src={useBaseUrl('img/add-plausible-script-to-carrd.png')} />
@@ -41,97 +39,25 @@ Now you can go to your Carrd website and verify that Plausible script has been a
41
39
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.
42
40
:::
43
41
44
-
### 1. Enable "Custom events" for your site
45
-
46
-
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).
47
-
48
-
### 2. Change the snippet on your site
49
-
50
-
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).
51
-
52
-
### 3. Trigger custom events with JavaScript on your site
53
-
54
-
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.
55
-
56
-
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.
57
-
58
-
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.
59
-
60
-
:::tip To represent a space character in goal names, you can use a `+` sign
61
-
For example: `plausible-event-name=Form+Submit` will display as `Form Submit` in your Plausible dashboard
62
-
:::
63
-
64
-
```html
65
-
<script>
66
-
var toTag = [
67
-
{
68
-
elementId:'form01',
69
-
classes:'plausible-event-name=Form+Submit'
70
-
}
71
-
]
72
-
73
-
document.addEventListener('DOMContentLoaded', function (_e) {
74
-
toTag.forEach(function (tagObject) {
75
-
var element =document.getElementById(tagObject.elementId)
<img alt="Modify Plausible script Carrd for form tracking" src={useBaseUrl('img/track-form-submissions-carrd.png')} />
85
-
86
-
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
87
-
88
-
```html
89
-
<script>
90
-
var toTag = [
91
-
{
92
-
elementId:'form01',
93
-
classes:'plausible-event-name=Form+Submit'
94
-
}
95
-
]
96
-
97
-
document.addEventListener('DOMContentLoaded', function (_e) {
98
-
toTag.forEach(function (tagObject) {
99
-
var element =document.getElementById(tagObject.elementId)
<img alt="On success form tracking in Carrd" src={useBaseUrl('img/track-form-submissions-submit-carrd.png')} />
42
+
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).
109
43
110
44
## Tracking button clicks and other links on your Carrd site
111
45
112
-
### 1. Enable "Custom events" for your site
113
-
114
-
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).
115
-
116
-
### 2. Change the snippet on your site
46
+
### 1. Set an ID to the element you want to track
117
47
118
-
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).
48
+
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.
119
49
120
-
### 3. Set an ID to the element you want to track
50
+
If you're on a higher plan, like Pro Plus, you'll be able to set these IDs yourself from the element's settings.
121
51
122
-
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.
123
-
124
-
If you're on a higher plan, like Pro Plus, you'll be able to set these IDs yourself from the element's settings.
125
-
126
-
To be sure of your element's ID, you can use your browser's dev tool to inspect the element.
52
+
To be sure of your element's ID, you can use your browser's dev tool to inspect the element.
127
53
128
54
<img alt="Confirm element ID in Carrd" src={useBaseUrl('img/confirm-element-id-carrd.png')} />
129
55
130
-
### 4. Trigger custom events with JavaScript on your site
56
+
### 2. Trigger custom events with JavaScript on your site
131
57
132
58
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.
133
59
134
-
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).
60
+
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).
135
61
136
62
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.
137
63
@@ -159,21 +85,21 @@ Also do change the `classes` line to include the goal name in this format: `plau
159
85
160
86
Do click on the "**Save Changes**" button and then "**Publish**" your changes.
161
87
162
-
### 5. Create a custom event goal in your Plausible account
88
+
### 3. Create a custom event goal in your Plausible account
163
89
164
90
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.
165
91
166
-
To configure a goal, go to [your website's settings](website-settings.md) in your Plausible account and visit the "**Goals**" section.
92
+
To configure a goal, go to [your website's settings](website-settings.md) in your Plausible account and visit the "**Goals**" section.
167
93
168
94
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.
169
95
170
96
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).
171
97
172
98
<img alt="Add your custom event goal" src={useBaseUrl('img/button-click-custom-event-goal-carrd.png')} />
173
99
174
-
Next, click on the "**Add goal**" button and you'll be taken back to the Goals page.
100
+
Next, click on the "**Add goal**" button and you'll be taken back to the Goals page.
175
101
176
-
### 6. Your goal should now be ready and tracking
102
+
### 4. Your goal should now be ready and tracking
177
103
178
104
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.
179
105
@@ -186,11 +112,11 @@ If you want to trigger multiple custom events on the same site, you don't need t
Copy file name to clipboardExpand all lines: docs/custom-automatic-link-tracking.md
+5-41Lines changed: 5 additions & 41 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,25 +10,17 @@ If you track link clicks, then these count towards your billable monthly pagevie
10
10
11
11
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.
12
12
13
-
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`.
13
+
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`.
14
14
15
15
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.
16
16
17
17
Here's how to automatically track clicks on cloaked affiliate links and other pretty URLs:
18
18
19
-
:::tip Our WordPress plugin can track cloaked affiliate links automatically
19
+
:::tip Our WordPress plugin can track cloaked affiliate links automatically
20
20
On WordPress? Check out our WordPress plugin which can track cloaked affiliate links automatically. [See more here](https://plausible.io/wordpress-analytics-plugin).
21
21
:::
22
22
23
-
## 1. Trigger custom events with JavaScript on your site
24
-
25
-
First, make sure your tracking setup includes the second line as shown below:
## 2. Add the JavaScript that will be sending the link click events to Plausible
23
+
## 1. Add the JavaScript that will be sending the link click events to Plausible
32
24
33
25
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.
34
26
@@ -43,15 +35,6 @@ On the line that says `var toBeTracked = '/go/'` change `/go/` to what you want
43
35
return link
44
36
}
45
37
46
-
functionshouldFollowLink(event, link) {
47
-
// If default has been prevented by an external script, Plausible should not intercept navigation.
48
-
if (event.defaultPrevented) { returnfalse }
49
-
50
-
var targetsCurrentWindow =!link.target||link.target.match(/^_(self|parent|top)$/i)
51
-
var isRegularClick =!(event.ctrlKey||event.metaKey||event.shiftKey) &&event.type==='click'
52
-
return targetsCurrentWindow && isRegularClick
53
-
}
54
-
55
38
varMIDDLE_MOUSE_BUTTON=1
56
39
57
40
functionhandleLinkClick(event) {
@@ -62,26 +45,7 @@ On the line that says `var toBeTracked = '/go/'` change `/go/` to what you want
@@ -109,7 +73,7 @@ If simply containing a substring is not enough to differentiate between links yo
109
73
110
74
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`.
111
75
112
-
## 3. Create a custom event goal in your Plausible Analytics account
76
+
## 2. Create a custom event goal in your Plausible Analytics account
113
77
114
78
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.
115
79
@@ -119,6 +83,6 @@ Click on the "**+ Add goal**" button to go to the goal creation form.
119
83
120
84
Select `Custom event` as the goal trigger and enter this exact name: `Cloaked Link: Click`.
121
85
122
-
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.
86
+
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.
123
87
124
88
That's it. You're now tracking all link clicks on your site with custom URL matching rules!
0 commit comments