Open source alternative to Semrush and Ahrefs
TypeScript backlink-analysisgoogle-search-console-mcpkeyword-researchmcpseoseo-agentseo-auditseo-automationseo-skillsseo-toolssite-audit
Count marketing-site visits with OpenAnalytics alongside Plausible (#1045)
Ben Senescu7464bf4e80d8
diff --git a/web/src/components/privacy-choices.tsx b/web/src/components/privacy-choices.tsxindex 5041d385..75b56a10 100644--- a/web/src/components/privacy-choices.tsx+++ b/web/src/components/privacy-choices.tsx@@ -11,12 +11,12 @@ import {const OPEN_PRIVACY_CHOICES_EVENT = "openseo:open-privacy-choices";const PLAUSIBLE_IGNORE = "plausible_ignore";-// Plausible counts visits without cookies for everyone (the dialog offers its-// opt-out). The consent-based tracking here is the Meta Pixel and Dub's-// referral cookie on partner links. Each loads where the visitor's choice or-// region allows it; where opt-in is required, visitors from a partner link or-// one of our Meta ads are asked. The footer's dialog also holds the app's-// analytics choice (one shared cookie).+// Plausible and OpenAnalytics count visits without cookies for everyone (the+// dialog offers one opt-out for both). The consent-based tracking here is the+// Meta Pixel and Dub's referral cookie on partner links. Each loads where the+// visitor's choice or region allows it; where opt-in is required, visitors+// from a partner link or one of our Meta ads are asked. The footer's dialog+// also holds the app's analytics choice (one shared cookie).export function PrivacyChoices() {const [saved, setSaved] =React.useState<ReturnType<typeof readPrivacyCookie>>(null);@@ -86,7 +86,9 @@ export function PrivacyChoices() {(!next.referrals &&document.querySelector("script[data-openseo-dub]") !== null) ||(!next.advertising &&- document.querySelector("script[data-openseo-meta]") !== null);+ document.querySelector("script[data-openseo-meta]") !== null) ||+ (localStorage.getItem(PLAUSIBLE_IGNORE) === "true" &&+ document.querySelector("script[data-openseo-openanalytics]") !== null);savePrivacyChoices(next);setSaved(next);setView("none");@@ -145,7 +147,8 @@ function ChoicesForm({<formonSubmit={(event) => {event.preventDefault();- // Plausible's own opt-out: its script skips tracking while this is set.+ // Plausible's own opt-out: its script skips tracking while this is set,+ // and the root loader skips OpenAnalytics.if (countVisits) localStorage.removeItem(PLAUSIBLE_IGNORE);else localStorage.setItem(PLAUSIBLE_IGNORE, "true");onSave(draft);@@ -155,7 +158,7 @@ function ChoicesForm({<div className="mt-3 space-y-3"><ChoiceRowlabel="Visit counts"- description="Anonymous, without cookies (Plausible)."+ description="No cookies or IDs saved in your browser (Plausible and OpenAnalytics)."checked={countVisits}onChange={setCountVisits}/>diff --git a/web/src/routes/__root.tsx b/web/src/routes/__root.tsxindex 3810a238..e6963675 100644--- a/web/src/routes/__root.tsx+++ b/web/src/routes/__root.tsx@@ -59,12 +59,13 @@ function RootDocument({ children }: { children: React.ReactNode }) {<html lang="en" suppressHydrationWarning><head><HeadContent />- {/* Plausible counts visits without cookies, so it runs for everyone.- Deferred to idle so it never competes with the page's own work. */}+ {/* Plausible and OpenAnalytics count visits without cookies, so they run+ for everyone; the Visit counts opt-out (plausible_ignore) skips both.+ Deferred to idle so they never compete with the page's own work. */}<scriptdangerouslySetInnerHTML={{__html:- "(function(){function loadAnalytics(){if(window.__openSeoAnalyticsLoaded)return;window.__openSeoAnalyticsLoaded=true;window.plausible=window.plausible||function(){(plausible.q=plausible.q||[]).push(arguments)};plausible.init=plausible.init||function(i){plausible.o=i||{}};plausible.init({endpoint:'/api/event'});var script=document.createElement('script');script.defer=true;script.src='/js/script.js';document.head.appendChild(script)}function schedule(){if('requestIdleCallback'in window){window.requestIdleCallback(loadAnalytics,{timeout:2000});return}window.setTimeout(loadAnalytics,2000)}if(document.readyState==='complete'){schedule();return}window.addEventListener('load',schedule,{once:true})})();",+ "(function(){function loadAnalytics(){if(window.__openSeoAnalyticsLoaded)return;window.__openSeoAnalyticsLoaded=true;window.plausible=window.plausible||function(){(plausible.q=plausible.q||[]).push(arguments)};plausible.init=plausible.init||function(i){plausible.o=i||{}};plausible.init({endpoint:'/api/event'});var script=document.createElement('script');script.defer=true;script.src='/js/script.js';document.head.appendChild(script);try{if(localStorage.getItem('plausible_ignore')==='true')return}catch(e){}var openAnalytics=document.createElement('script');openAnalytics.defer=true;openAnalytics.src='https://analytics.everyapp.team/script.js?siteId=72114522-d4bd-4f7e-b73b-62ccdaeae482';openAnalytics.setAttribute('data-openseo-openanalytics','');document.head.appendChild(openAnalytics)}function schedule(){if('requestIdleCallback'in window){window.requestIdleCallback(loadAnalytics,{timeout:2000});return}window.setTimeout(loadAnalytics,2000)}if(document.readyState==='complete'){schedule();return}window.addEventListener('load',schedule,{once:true})})();",}}/></head>