Custom code on lykhari
Lykhari now has custom code.
You can paste any snippet into your settings and it gets added to the end of every page on your blog. Analytics, a widget, a font, a st anything that needs a script or a tag.
It is in Dashboard → Settings, search "custom code".
This feature solves the analytics problems. Some people want Google Analytics. Some want ethical alternatives. We can't have them all. Custom code fixes all of that.
I could have built a setting for each. That is how platforms get bloated, one reasonable request at a time, until the settings page is four screens long and half of it is switches nobody touches.
So instead of ten settings, one box.
Google Analytics
The most common ask. Create a property in Google Analytics, copy the measurement ID, and paste this in, replacing both instances of G-XXXXXXXXXX with yours.
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXXXXXXXX');
</script>Visit your blog, then look at Realtime in Google Analytics. You should see yourself.
Other things you can use it for.
A chat or support widget, if you want readers to be able to reach you without email.
A custom font, by pasting the link tag your font provider gives you.
Plausible, Fathom, or any other analytics that is lighter than Google's.
A newsletter form from a service you already pay for, if you would rather use that than the built-in one.
Small bits of CSS in a style tag, for the one thing about your theme you want different.
What to know
The code runs as written. I do not check it, sanitize it, or fix it. That is the point, and it is also the risk: a broken snippet can break your blog. If something looks wrong, empty the box and save, and it is gone immediately.
It runs on your blog only, never on your dashboard.
There is a 10,000 character limit. Analytics snippets are a few hundred characters, so this is only a problem if you are pasting something that probably belongs in a file.
Custom code is a pro feature, so it needs the $5/month plan.
There is a walkthrough in the faqs if you want the steps written out.