-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
50 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import Script from "next/script"; | ||
import { GOOGLE_TAG_MANAGER_ID, KOALA_URL } from "../lib/env"; | ||
|
||
export function Analytics() { | ||
return ( | ||
<> | ||
{GOOGLE_TAG_MANAGER_ID && ( | ||
<> | ||
<Script | ||
id="gtm" | ||
async | ||
dangerouslySetInnerHTML={{ | ||
__html: `(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': | ||
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], | ||
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= | ||
'https://ta.zuplo.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); | ||
})(window,document,'script','dataLayer','${GOOGLE_TAG_MANAGER_ID}');`, | ||
}} | ||
/> | ||
</> | ||
)} | ||
{GOOGLE_TAG_MANAGER_ID && ( | ||
<Script id="gtm2"> | ||
{`window.dataLayer = window.dataLayer || []; | ||
function gtag(){dataLayer.push(arguments);} | ||
gtag('js', new Date()); | ||
gtag('config', '${GOOGLE_TAG_MANAGER_ID}', {'allow_enhanced_conversions':true});`} | ||
</Script> | ||
)} | ||
{KOALA_URL && ( | ||
<Script | ||
id="koala-analytics" | ||
strategy="afterInteractive" | ||
async | ||
dangerouslySetInnerHTML={{ | ||
__html: ` | ||
window.koalaSettings = { host: '${KOALA_URL}' }; | ||
!function(t){if(window.ko)return;window.ko=[],["identify","track","removeListeners","open","on","off","qualify","ready"].forEach(function(t){ko[t]=function(){var n=[].slice.call(arguments);return n.unshift(t),ko.push(n),ko}});var n=document.createElement("script");n.async=!0,n.setAttribute("src","${KOALA_URL}/v1/pk_32d64a435a311ccc9462e3721dba58cb3e35/sdk.js"),(document.body || document.head).appendChild(n)}();`, | ||
}} | ||
/> | ||
)} | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
// Analytics | ||
export const POSTHOG_KEY = process.env.NEXT_PUBLIC_POSTHOG_KEY; | ||
export const POSTHOG_URL = process.env.NEXT_PUBLIC_POSTHOG_URL; | ||
export const ZARAZ_URL = process.env.NEXT_PUBLIC_ZARAZ_URL; | ||
export const KOALA_URL = process.env.NEXT_PUBLIC_KOALA_URL; | ||
export const REDDIT_PIXEL_ID = process.env.NEXT_PUBLIC_REDDIT_PIXEL_ID; | ||
export const GOOGLE_TAG_MANAGER_ID = | ||
process.env.NEXT_PUBLIC_GOOGLE_TAG_MANAGER_ID; | ||
export const TWITTER_PIXEL_ID = process.env.NEXT_PUBLIC_TWITTER_PIXEL_ID; | ||
export const KOALA_URL = process.env.NEXT_PUBLIC_KOALA_URL; |