-
Notifications
You must be signed in to change notification settings - Fork 1
Fix plausible script tags and make them configurable #105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the catch @rogermparent.
We use websites-server
on all our websites. The proxy should be available to all the websites themselves i.e we will not need the dvc.org
prefix.
For convenience, we can
- set the plausibleSrc to
/pl/js/script.outbound-links.js
or/pl/js/script.js
by default, - we will also need plausibleAPI which we can set to
/pl/api/event
by default, - for
plausibleDomain
I think we can extract it from siteUrl metadata. Instead, we can replaceplausibleDomain
with a flag variable(which is set to true by default) and set it to false in case we don't want to use it(for instance, the gatsby-theme-iterative example website).
This way we have fewer configurations to do on consumer websites and we can replace the variable only when it's necessary.
20599ac
to
990a959
Compare
I'm struggling to find out where we actually put |
{plausibleDomainOrDefault ? ( | ||
<script | ||
defer | ||
data-domain={plausibleDomainOrDefault} | ||
src={plausibleSrc} | ||
/> | ||
) : null} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
falsiness can be triggered with a plausibleDomain
of ''
, but that API will be improved in the next revision.
Found it! It's just |
@@ -172,7 +172,8 @@ module.exports = ({ | |||
], | |||
siteMetadata: { | |||
author: 'Iterative', | |||
siteUrl: 'https://cml.dev', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can get away with a lot of plug-and-play for our websites, but I think we shouldn't have a default show through on siteUrl, especially not cml.dev
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We provide siteUrl
for individual websites, so we don't need a default value. It will be required field for individual website.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Nice work @rogermparent.
* Add plausible through metadata * Use Gatsby SiteMetadata for plausible domain and src * Use automatic plausible inference and relative proxy source links * Disable plausible on example * v0.1.23 * Add plausibleAPI * Re-disable plausible in example * Fix conditional plausible disable * Re-add defaults for max compatibility * Use disablePlausible flag and change mechanism to signal with src * Use pluginOptions for src/api/domain and use src presence over extra boolean flag * Allow null on plausible options * Change src to null
…main) (#123) * Fix plausible script tags and make them configurable (#105) * Add plausible through metadata * Use Gatsby SiteMetadata for plausible domain and src * Use automatic plausible inference and relative proxy source links * Disable plausible on example * v0.1.23 * Add plausibleAPI * Re-disable plausible in example * Fix conditional plausible disable * Re-add defaults for max compatibility * Use disablePlausible flag and change mechanism to signal with src * Use pluginOptions for src/api/domain and use src presence over extra boolean flag * Allow null on plausible options * Change src to null * Fix gatsby-ssr
Hi. Now that this has been merged everywhere, should we setup some follow-up date to check on the bounce rates? |
I've actually been checking in the whole time! Bounce rates went down immediately after the initial quickfix, and have stayed at that same low/normal level with all other metrics normal ever since the merge. My last check was Monday, and I planned to give yet another Friday for extra measure. |
Before, the plausible scripts added by this theme were:
Script
tag put them at the bottom.dvc.org
😬This PR changes that by turning the plausible domain and script source into options configurable via Gatsby's
siteMetadata
feature under the keysplausibleDomain
andplausibleSrc
.plausibleDomain
determines the domain the site reports to Plausible as, and if it isn't specified the domain is inferred fromsiteMetadata.siteUrl
plausibleSrc
allows us to specify thesrc
tag of the plausible script, defaulting to ourwebsites-server
-proxied version of theoutbound-links
script. Cases where this would be overridden would include:outbound-links
version of the scriptwebsites-server
This will change once we shift toward making this more useful to the public
maintenance
branch that reverts #33, so we can make a bugfix release on the 0.1 line and make this fix get in ASAPHere's an example of the resulting script tag
