-
Notifications
You must be signed in to change notification settings - Fork 23
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
Documentation for next.js 13 app directory? #112
Comments
@philippkeller Did you figure this out? |
Also looking for this solution |
need a solution as well 😕 |
@revolunet yes the code snippet in #104 looks good - where do I add it though? into src/app/layout.jsx ? |
I got something working, but it's probably far from perfect: In
then, above the tag add In import Script from "next/script";
const MATOMO_URL = process.env.NEXT_PUBLIC_MATOMO_URL;
const MATOMO_SITE_ID = process.env.NEXT_PUBLIC_MATOMO_SITE_ID;
export default function Matomo() {
return (
<Script
id="matomo"
strategy="afterInteractive"
dangerouslySetInnerHTML={{
__html: `
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//${MATOMO_URL}/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '${MATOMO_SITE_ID}']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
`,
}}
/>
)
} And in your .env file:
|
@philippkeller FYI you don't need
|
The docs only cover the pages directory (using
_app.jsx
).I want to use it with the new app directory, but I'm lost.
The best I could find was this howto which covers PostHog.
Could anyone help out here?
The text was updated successfully, but these errors were encountered: