add analytics

This commit is contained in:
Cory Dransfeldt 2022-06-07 16:33:59 -07:00
parent ce3d02cab6
commit 3981af5581
3 changed files with 18 additions and 9 deletions

View file

@ -8,11 +8,12 @@ const PlausibleScript = () => {
<Script
strategy="lazyOnload"
data-domain={siteMetadata.analytics.plausibleDataDomain}
src="https://plausible.io/js/plausible.js"
data-api={siteMetadata.analytics.plausibleApiUrl}
src={siteMetadata.analytics.plausibleSrcUrl}
/>
<Script strategy="lazyOnload" id="plausible-script">
{`
window.plausible = window.plausible || function() { (window.plausible.q = window.plausible.q || []).push(arguments) }
window.plausible = window.plausible || function() { (window.plausible.q = window.plausible.q || []).push(arguments) }
`}
</Script>
</>

View file

@ -22,13 +22,9 @@ const siteMetadata = {
lastfm: 'https://www.last.fm/music/augury',
locale: 'en-CA',
analytics: {
// If you want to use an analytics provider you have to add it to the
// content security policy in the `next.config.js` file.
// supports plausible, simpleAnalytics, umami or googleAnalytics
plausibleDataDomain: '', // e.g. tailwind-nextjs-starter-blog.vercel.app
simpleAnalytics: false, // true or false
umamiWebsiteId: '', // e.g. 123e4567-e89b-12d3-a456-426614174000
googleAnalyticsId: '', // e.g. UA-000000-2 or G-XXXXXXX
plausibleDataDomain: 'augurymetal.com',
plausibleSrcUrl: '/script.12587e3213z2t1891zaz.js',
plausibleApiUrl: '/api/12761a4481f2x6771zab',
},
newsletter: {
// supports mailchimp, buttondown, convertkit, klaviyo

View file

@ -69,6 +69,18 @@ module.exports = withBundleAnalyzer({
},
]
},
async rewrites() {
return [
{
source: '/script.12587e3213z2t1891zaz.js', // plausible script proxy
destination: 'https://plausible.io/js/script.outbound-links.js',
},
{
source: '/api/12761a4481f2x6771zab', // plausible api proxy
destination: 'https://plausible.io/api/event',
},
]
},
webpack: (config, { dev, isServer }) => {
config.module.rules.push({
test: /\.(png|jpe?g|gif|mp4)$/i,