Created
February 26, 2022 11:16
-
-
Save montalvomiguelo/3a8da3b6db29091ecb4b04265a58bd3b to your computer and use it in GitHub Desktop.
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title></title> | |
<!-- Partytown config --> | |
<script> | |
partytown = { | |
debug: true, | |
lib: '/a/partytown/', | |
forward: [ | |
'abandonment_tracked', | |
'ShopifyAnalytics', | |
'ShopifyAnalytics.meta', | |
'ShopifyAnalytics.meta.currency', | |
'ShopifyAnalytics.meta[attr]', | |
'ShopifyAnalytics.merchantGoogleAnalytics', | |
'gaDevIds', | |
'ShopifyAnalytics.lib', | |
'trekkie', | |
'trekkie.methods', | |
'trekkie.factory', | |
'trekkie.load', | |
'trekkie.config', | |
'trekkie.config.initialDocumentCookie', | |
'BOOMR', | |
'BOOMR.snippetStart', | |
'BOOMR.snippetExecuted', | |
'BOOMR.snippetVersion', | |
'BOOMR.application', | |
'BOOMR.themeName', | |
'BOOMR.themeVersion', | |
'BOOMR.shopId', | |
'BOOMR.themeId', | |
'BOOMR.url', | |
'BOOMR.snippetMethod', | |
'BOOMR_onload' | |
], | |
resolveUrl: function(url) { | |
if (url.hostname === 'www.google-analytics.com' || url.hostname === 'connect.facebook.net') { | |
var proxyUrl = new URL('https://reverse-proxy.montalvomiguelo.workers.dev'); | |
proxyUrl.searchParams.append('url', url.href); | |
return proxyUrl; | |
} | |
return url; | |
}, | |
logCalls: true, | |
logGetters: true, | |
logImageRequests: true, | |
logMainAccess: true, | |
logScriptExecution: true, | |
logSendBeaconRequests: true, | |
logSetters: true, | |
logStackTraces: false | |
}; | |
</script> | |
<script> | |
/* Partytown 0.3.6 - MIT builder.io */ | |
!function(t,e,n,i,r,o,a,d,s,c,p,l){function u(){l||(l=1,"/"==(a=(o.lib||"/~partytown/")+(o.debug?"debug/":""))[0]&&(s=e.querySelectorAll('script[type="text/partytown"]'),i!=t?i.dispatchEvent(new CustomEvent("pt1",{detail:t})):s.length&&(d=setTimeout(f,1e4),e.addEventListener("pt0",g),r?h(1):n.serviceWorker?n.serviceWorker.register(a+"partytown-sw.js",{scope:a}).then((function(t){t.active?h():t.installing&&t.installing.addEventListener("statechange",(function(t){"activated"==t.target.state&&h()}))}),console.error):f())))}function h(t){c=e.createElement(t?"script":"iframe"),t||(c.setAttribute("style","display:block;width:0;height:0;border:0;visibility:hidden"),c.setAttribute("aria-hidden",!0)),c.src=a+"partytown-"+(t?"atomics.js":"sandbox-sw.html?"+Date.now()),e.body.appendChild(c)}function f(t,n){for(g(),t=0;t<s.length;t++)(n=e.createElement("script")).innerHTML=s[t].innerHTML,e.head.appendChild(n);c&&c.parentNode.removeChild(c)}function g(){clearTimeout(d)}o=t.partytown||{},i==t&&(o.forward||[]).map((function(e){p=t,e.split(".").map((function(e,n,i){p=p[i[n]]=n+1<i.length?"push"==i[n+1]?[]:p[i[n]]||{}:function(){(t._ptf=t._ptf||[]).push(i,arguments)}}))})),"complete"==e.readyState?u():(t.addEventListener("DOMContentLoaded",u),t.addEventListener("load",u))}(window,document,navigator,top,top.crossOriginIsolated); | |
</script> | |
<!-- Attach the type="text/partytown" to Shopify's inline scripts --> | |
<script> | |
(function() { | |
const observer = new MutationObserver(function(mutations) { | |
mutations.forEach(function(mutation) { | |
mutation.addedNodes.forEach(function(node) { | |
if (node.nodeType !== 1 || node.tagName !== 'SCRIPT') { | |
return; | |
} | |
if (node.getAttribute('src')) { | |
return; | |
} | |
node.type = 'text/partytown'; | |
node.addEventListener('beforescriptexecute', beforeScriptExecuteListener); | |
function beforeScriptExecuteListener(evt) { | |
if(node.getAttribute('type') === 'text/partytown') { | |
evt.preventDefault(); | |
} | |
node.removeEventListener('beforescriptexecute', beforeScriptExecuteListener); | |
} | |
}); | |
}); | |
}); | |
observer.observe(document.head, { | |
childList: true, | |
subtree: true | |
}); | |
}()); | |
</script> | |
<!-- Shopify's stuff --> | |
<script> | |
(function() { | |
if ("sendBeacon" in navigator && "performance" in window) { | |
var session_token = document.cookie.match(/_shopify_s=([^;]*)/); | |
function handle_abandonment_event(e) { | |
var entries = performance.getEntries().filter(function(entry) { | |
return /monorail-edge.shopifysvc.com/.test(entry.name); | |
}); | |
if (!window.abandonment_tracked && entries.length === 0) { | |
window.abandonment_tracked = true; | |
var currentMs = Date.now(); | |
var navigation_start = performance.timing.navigationStart; | |
var payload = { | |
shop_id: 57348849821, | |
url: window.location.href, | |
navigation_start, | |
duration: currentMs - navigation_start, | |
session_token: session_token && session_token.length === 2 ? session_token[1] : "", | |
page_type: "index" | |
}; | |
window.navigator.sendBeacon("https://monorail-edge.shopifysvc.com/v1/produce", JSON.stringify({ | |
schema_id: "online_store_buyer_site_abandonment/1.1", | |
payload: payload, | |
metadata: { | |
event_created_at_ms: currentMs, | |
event_sent_at_ms: currentMs | |
} | |
})); | |
} | |
} | |
window.addEventListener('pagehide', handle_abandonment_event); | |
} | |
}()); | |
</script> | |
<script> | |
window.ShopifyAnalytics = window.ShopifyAnalytics || {}; | |
window.ShopifyAnalytics.meta = window.ShopifyAnalytics.meta || {}; | |
window.ShopifyAnalytics.meta.currency = 'USD'; | |
var meta = { | |
"page": { | |
"pageType": "home" | |
} | |
}; | |
for (var attr in meta) { | |
window.ShopifyAnalytics.meta[attr] = meta[attr]; | |
} | |
</script> | |
<script> | |
window.ShopifyAnalytics.merchantGoogleAnalytics = function() { | |
}; | |
</script> | |
<script class="analytics"> | |
(window.gaDevIds = window.gaDevIds || []).push('BwiEti'); | |
(function() { | |
var customDocumentWrite = function(content) { | |
var jquery = null; | |
if (window.jQuery) { | |
jquery = window.jQuery; | |
} else if (window.Checkout && window.Checkout.$) { | |
jquery = window.Checkout.$; | |
} | |
if (jquery) { | |
jquery('body').append(content); | |
} | |
}; | |
var hasLoggedConversion = function(token) { | |
if (token) { | |
return document.cookie.indexOf('loggedConversion=' + token) !== -1; | |
} | |
return false; | |
} | |
var setCookieIfConversion = function(token) { | |
if (token) { | |
var twoMonthsFromNow = new Date(Date.now()); | |
twoMonthsFromNow.setMonth(twoMonthsFromNow.getMonth() + 2); | |
document.cookie = 'loggedConversion=' + token + '; expires=' + twoMonthsFromNow; | |
} | |
} | |
var trekkie = window.ShopifyAnalytics.lib = window.trekkie = window.trekkie || []; | |
if (trekkie.integrations) { | |
return; | |
} | |
trekkie.methods = [ | |
'identify', | |
'page', | |
'ready', | |
'track', | |
'trackForm', | |
'trackLink' | |
]; | |
trekkie.factory = function(method) { | |
return function() { | |
var args = Array.prototype.slice.call(arguments); | |
args.unshift(method); | |
trekkie.push(args); | |
return trekkie; | |
}; | |
}; | |
for (var i = 0; i < trekkie.methods.length; i++) { | |
var key = trekkie.methods[i]; | |
trekkie[key] = trekkie.factory(key); | |
} | |
trekkie.load = function(config) { | |
trekkie.config = config || {}; | |
trekkie.config.initialDocumentCookie = document.cookie; | |
var first = document.getElementsByTagName('script')[0]; | |
var script = document.createElement('script'); | |
script.type = 'text/javascript'; | |
script.onerror = function(e) { | |
var scriptFallback = document.createElement('script'); | |
scriptFallback.type = 'text/javascript'; | |
scriptFallback.onerror = function(error) { | |
var Monorail = { | |
produce: function produce(monorailDomain, schemaId, payload) { | |
var currentMs = new Date().getTime(); | |
var event = { | |
schema_id: schemaId, | |
payload: payload, | |
metadata: { | |
event_created_at_ms: currentMs, | |
event_sent_at_ms: currentMs | |
} | |
}; | |
return Monorail.sendRequest("https://" + monorailDomain + "/v1/produce", JSON.stringify(event)); | |
}, | |
sendRequest: function sendRequest(endpointUrl, payload) { | |
// Try the sendBeacon API | |
if (window && window.navigator && typeof window.navigator.sendBeacon === 'function' && typeof window.Blob === 'function' && !Monorail.isIos12()) { | |
var blobData = new window.Blob([payload], { | |
type: 'text/plain' | |
}); | |
if (window.navigator.sendBeacon(endpointUrl, blobData)) { | |
return true; | |
} // sendBeacon was not successful | |
} // XHR beacon | |
var xhr = new XMLHttpRequest(); | |
try { | |
xhr.open('POST', endpointUrl); | |
xhr.setRequestHeader('Content-Type', 'text/plain'); | |
xhr.send(payload); | |
} catch (e) { | |
console.log(e); | |
} | |
return false; | |
}, | |
isIos12: function isIos12() { | |
return window.navigator.userAgent.lastIndexOf('iPhone; CPU iPhone OS 12_') !== -1 || window.navigator.userAgent.lastIndexOf('iPad; CPU OS 12_') !== -1; | |
} | |
}; | |
Monorail.produce('monorail-edge.shopifysvc.com', | |
'trekkie_storefront_load_errors/1.1', { | |
shop_id: 57348849821, | |
theme_id: 128806781085, | |
app_name: "storefront", | |
context_url: window.location.href, | |
source_url: "https://cdn.shopify.com/s/trekkie.storefront.6a93d7d0eebeebb777036b0098935be9cb2b573b.min.js" | |
}); | |
}; | |
scriptFallback.async = true; | |
scriptFallback.src = 'https://cdn.shopify.com/s/trekkie.storefront.6a93d7d0eebeebb777036b0098935be9cb2b573b.min.js'; | |
first.parentNode.insertBefore(scriptFallback, first); | |
}; | |
script.async = true; | |
script.src = 'https://cdn.shopify.com/s/trekkie.storefront.6a93d7d0eebeebb777036b0098935be9cb2b573b.min.js'; | |
first.parentNode.insertBefore(script, first); | |
}; | |
trekkie.load({ | |
"Trekkie": { | |
"appName": "storefront", | |
"development": false, | |
"defaultAttributes": { | |
"shopId": 57348849821, | |
"isMerchantRequest": null, | |
"themeId": 128806781085, | |
"themeCityHash": "12460288588621117854", | |
"contentLanguage": "en", | |
"currency": "USD" | |
}, | |
"isServerSideCookieWritingEnabled": true | |
}, | |
"Google Analytics": { | |
"trackingId": "UA-205277178-1", | |
"domain": "auto", | |
"siteSpeedSampleRate": "10", | |
"enhancedEcommerce": true, | |
"doubleClick": true, | |
"includeSearch": true | |
}, | |
"Facebook Pixel": { | |
"pixelIds": ["421005402785898"], | |
"agent": "plshopify1.2" | |
}, | |
"Session Attribution": {}, | |
"S2S": { | |
"facebookCapiEnabled": true, | |
"facebookAppPixelId": "421005402785898", | |
"source": "trekkie-storefront-renderer" | |
} | |
}); | |
var loaded = false; | |
trekkie.ready(function() { | |
if (loaded) return; | |
loaded = true; | |
window.ShopifyAnalytics.lib = window.trekkie; | |
ga('require', 'linker'); | |
function addListener(element, type, callback) { | |
if (element.addEventListener) { | |
element.addEventListener(type, callback); | |
} else if (element.attachEvent) { | |
element.attachEvent('on' + type, callback); | |
} | |
} | |
function decorate(event) { | |
event = event || window.event; | |
var target = event.target || event.srcElement; | |
if (target && (target.getAttribute('action') || target.getAttribute('href'))) { | |
ga(function(tracker) { | |
var linkerParam = tracker.get('linkerParam'); | |
document.cookie = '_shopify_ga=' + linkerParam + '; ' + 'path=/'; | |
}); | |
} | |
} | |
addListener(window, 'load', function() { | |
for (var i = 0; i < document.forms.length; i++) { | |
var action = document.forms[i].getAttribute('action'); | |
if (action && action.indexOf('/cart') >= 0) { | |
addListener(document.forms[i], 'submit', decorate); | |
} | |
} | |
for (var i = 0; i < document.links.length; i++) { | |
var href = document.links[i].getAttribute('href'); | |
if (href && href.indexOf('/checkout') >= 0) { | |
addListener(document.links[i], 'click', decorate); | |
} | |
} | |
}); | |
var originalDocumentWrite = document.write; | |
document.write = customDocumentWrite; | |
try { | |
window.ShopifyAnalytics.merchantGoogleAnalytics.call(this); | |
} catch (error) {}; | |
document.write = originalDocumentWrite; | |
(function() { | |
if (window.BOOMR && (window.BOOMR.version || window.BOOMR.snippetExecuted)) { | |
return; | |
} | |
window.BOOMR = window.BOOMR || {}; | |
window.BOOMR.snippetStart = new Date().getTime(); | |
window.BOOMR.snippetExecuted = true; | |
window.BOOMR.snippetVersion = 12; | |
window.BOOMR.application = "storefront-renderer"; | |
window.BOOMR.themeName = "Visionist"; | |
window.BOOMR.themeVersion = "1.0.22"; | |
window.BOOMR.shopId = 57348849821; | |
window.BOOMR.themeId = 128806781085; | |
window.BOOMR.url = | |
"https://cdn.shopify.com/shopifycloud/boomerang/shopify-boomerang-1.0.0.min.js"; | |
var where = document.currentScript || document.getElementsByTagName("script")[0]; | |
var parentNode = where.parentNode; | |
var promoted = false; | |
var LOADER_TIMEOUT = 3000; | |
function promote() { | |
if (promoted) { | |
return; | |
} | |
var script = document.createElement("script"); | |
script.id = "boomr-scr-as"; | |
script.src = window.BOOMR.url; | |
script.async = true; | |
parentNode.appendChild(script); | |
promoted = true; | |
} | |
function iframeLoader(wasFallback) { | |
promoted = true; | |
var dom, bootstrap, iframe, iframeStyle; | |
var doc = document; | |
var win = window; | |
window.BOOMR.snippetMethod = wasFallback ? "if" : "i"; | |
bootstrap = function(parent, scriptId) { | |
var script = doc.createElement("script"); | |
script.id = scriptId || "boomr-if-as"; | |
script.src = window.BOOMR.url; | |
BOOMR_lstart = new Date().getTime(); | |
parent = parent || doc.body; | |
parent.appendChild(script); | |
}; | |
if (!window.addEventListener && window.attachEvent && navigator.userAgent.match(/MSIE [67]./)) { | |
window.BOOMR.snippetMethod = "s"; | |
bootstrap(parentNode, "boomr-async"); | |
return; | |
} | |
iframe = document.createElement("IFRAME"); | |
iframe.src = "about:blank"; | |
iframe.title = ""; | |
iframe.role = "presentation"; | |
iframe.loading = "eager"; | |
iframeStyle = (iframe.frameElement || iframe).style; | |
iframeStyle.width = 0; | |
iframeStyle.height = 0; | |
iframeStyle.border = 0; | |
iframeStyle.display = "none"; | |
parentNode.appendChild(iframe); | |
try { | |
win = iframe.contentWindow; | |
doc = win.document.open(); | |
} catch (e) { | |
dom = document.domain; | |
iframe.src = "javascript:var d=document.open();d.domain='" + dom + "';void(0);"; | |
win = iframe.contentWindow; | |
doc = win.document.open(); | |
} | |
if (dom) { | |
doc._boomrl = function() { | |
this.domain = dom; | |
bootstrap(); | |
}; | |
doc.write("<body onload='document._boomrl();'>"); | |
} else { | |
win._boomrl = function() { | |
bootstrap(); | |
}; | |
if (win.addEventListener) { | |
win.addEventListener("load", win._boomrl, false); | |
} else if (win.attachEvent) { | |
win.attachEvent("onload", win._boomrl); | |
} | |
} | |
doc.close(); | |
} | |
var link = document.createElement("link"); | |
if (link.relList && | |
typeof link.relList.supports === "function" && | |
link.relList.supports("preload") && | |
("as" in link)) { | |
window.BOOMR.snippetMethod = "p"; | |
link.href = window.BOOMR.url; | |
link.rel = "preload"; | |
link.as = "script"; | |
link.addEventListener("load", promote); | |
link.addEventListener("error", function() { | |
iframeLoader(true); | |
}); | |
setTimeout(function() { | |
if (!promoted) { | |
iframeLoader(true); | |
} | |
}, LOADER_TIMEOUT); | |
BOOMR_lstart = new Date().getTime(); | |
parentNode.appendChild(link); | |
} else { | |
iframeLoader(false); | |
} | |
function boomerangSaveLoadTime(e) { | |
window.BOOMR_onload = (e && e.timeStamp) || new Date().getTime(); | |
} | |
if (window.addEventListener) { | |
window.addEventListener("load", boomerangSaveLoadTime, false); | |
} else if (window.attachEvent) { | |
window.attachEvent("onload", boomerangSaveLoadTime); | |
} | |
if (document.addEventListener) { | |
document.addEventListener("onBoomerangLoaded", function(e) { | |
e.detail.BOOMR.init({ | |
producer_url: "https://monorail-edge.shopifysvc.com/v1/produce", | |
ResourceTiming: { | |
enabled: true, | |
trackedResourceTypes: ["script", "img", "css"] | |
}, | |
}); | |
e.detail.BOOMR.t_end = new Date().getTime(); | |
}); | |
} else if (document.attachEvent) { | |
document.attachEvent("onpropertychange", function(e) { | |
if (!e) e = event; | |
if (e.propertyName === "onBoomerangLoaded") { | |
e.detail.BOOMR.init({ | |
producer_url: "https://monorail-edge.shopifysvc.com/v1/produce", | |
ResourceTiming: { | |
enabled: true, | |
trackedResourceTypes: ["script", "img", "css"] | |
}, | |
}); | |
e.detail.BOOMR.t_end = new Date().getTime(); | |
} | |
}); | |
} | |
})(); | |
window.ShopifyAnalytics.lib.page(null, { | |
"pageType": "home" | |
}); | |
var match = window.location.pathname.match(/checkouts\/(.+)\/(thank_you|post_purchase)/) | |
var token = match ? match[1] : undefined; | |
if (!hasLoggedConversion(token)) { | |
setCookieIfConversion(token); | |
} | |
}); | |
var eventsListenerScript = document.createElement('script'); | |
eventsListenerScript.async = true; | |
eventsListenerScript.src = "//cdn.shopify.com/shopifycloud/shopify/assets/shop_events_listener-fa61fd11817b231631d2fe43dc869d0b1d14a06332792d42f1a1d94bda5aa31e.js"; | |
document.getElementsByTagName('head')[0].appendChild(eventsListenerScript); | |
})(); | |
</script> | |
</head> | |
<body> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@montalvomiguelo I'm curious if you're using this or if you ever managed to get a good PartyTown integration with Shopify.