Skip to content
This repository has been archived by the owner on Jan 8, 2025. It is now read-only.

Adds Marketo script from GTM to Next Script #431

Merged
merged 3 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ NEXT_PUBLIC_POSTHOG_ENABLED=false
NEXT_PUBLIC_SANITY_PROJECT_ID=y1ellg96
NEXT_PUBLIC_SANITY_DATASET=production
SANITY_READ_TOKEN=""

MUNCHKIN_ID=""
31 changes: 31 additions & 0 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import "styles/global.css";

const NEXT_PUBLIC_GTM_ID = process.env.NEXT_PUBLIC_GTM_ID;
const NEXT_PUBLIC_GTAG_ID = process.env.NEXT_PUBLIC_GTAG_ID;
const MUNCHKIN_ID = process.env.MUNCHKIN_ID;

interface dataLayerItem {
[key: string]: unknown;
Expand All @@ -73,6 +74,36 @@ const Analytics = () => {
<Script id="add_dataLayer">
{`window.dataLayer = window.dataLayer || []`}
</Script>
{/* Munchin Script */}
{MUNCHKIN_ID && (
<>
<Script id="munchkin-script">
{`
(function() {
var didInit = false;
function initMunchkin() {
if(didInit === false) {
didInit = true;
Munchkin.init('${MUNCHKIN_ID}');
}
}
var s = document.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.src = '//munchkin.marketo.net/munchkin.js';
s.onreadystatechange = function() {
if (this.readyState == 'complete' || this.readyState == 'loaded') {
initMunchkin();
}
};
s.onload = initMunchkin;
document.getElementsByTagName('head')[0].appendChild(s);
})();
`}
</Script>
</>
)}
{/* End Munchin Script */}
{/* Script for adding Qualified (https://www.qualified.com/)*/}
<Script id="script_qualified">
{`
Expand Down
Loading