Skip to content

Instantly share code, notes, and snippets.

View md604's full-sized avatar

Maxim Dyuzhinov md604

View GitHub Profile
@md604
md604 / ga-custom.liquid
Last active February 28, 2021 23:30
ga-custom.liquid
{% if template.name == "product" %}
{% if product.metafields.ga.wake_up_elon and product.metafields.ga.wake_up_elon != blank %}
<script type="text/javascript">
window.gaCustomValues = {
'ec:addProduct': {
'dimension1': {{ product.metafields.ga.wake_up_elon | json }}
}
};
@md604
md604 / monorail_boot_script.js
Last active February 14, 2021 17:16
Monorail boot script in the header of the page
(function () {
...
// Step #1
// Load trekkie library and initialize all third-party trackers
trekkie.load(
{
"Trekkie": { ... },
"Session Attribution":{},
@md604
md604 / header_javascript.js
Created February 13, 2021 17:49
Call to the EE event function in the head of the product page
if (!hasLoggedConversion(token)) {
setCookieIfConversion(token);
window.ShopifyAnalytics.lib.track(
"Viewed Product",
{
"currency":"EUR",
"variantId":34686330142853,
"productId":5202279170181,
"productGid":"gid:\/\/shopify\/Product\/5202279170181",
@md604
md604 / trekkie.min.js
Created February 9, 2021 21:37
Add data to the tracker (lines: 614 - 621)
(t.prototype.viewedProductEnhanced = function (e) {
var t = e.properties;
this.loadEnhancedEcommerce(e);
/* ^^^^^ Function's definition:
(t.prototype.loadEnhancedEcommerce = function (e) {
this.enhancedEcommerceLoaded || (window.ga("require", "ec"),
(this.enhancedEcommerceLoaded = !0));
var t = e.properties;
window.ga("set", "&cu", this.getCurrency(t.currency));
})
@md604
md604 / trekkie.min.js
Created February 7, 2021 21:01
Init GA tracker (lines: 664-674)
(t.prototype.initialize = function (e) {
(this.pageCalled = !1), this.loadGAScript();
var n = this.options;
"localhost" === c.hostname() && (n.domain = "none"),
n.enhancedEcommerce && this.enhancedEcommerce(),
window.ga("create", n.trackingId, { cookieDomain: n.domain || t.defaultOptions.domain, siteSpeedSampleRate: n.siteSpeedSampleRate, sampleRate: n.sampleRate, allowLinker: !0 }),
n.doubleClick && window.ga("require", "displayfeatures"),
n.enhancedLinkAttribution && window.ga("require", "linkid"),
n.anonymizeIp && window.ga("set", "anonymizeIp", !0),
e();
@md604
md604 / trekkie.min.js
Created February 7, 2021 15:40
Loading GA scripts (lines: 675 - 687)
(t.prototype.setWindowGa = function () {
(window.ga && "function" == typeof window.ga) ||
(window.ga = function () {
(window.ga.q = window.ga.q || []).push(arguments);
});
}),
(t.prototype.loadGAScript = function () {
(window.GoogleAnalyticsObject = "ga"), this.setWindowGa(), (window.ga.l = new Date().getTime());
var e = s.virtualDocument().createElement("script");
(e.async = !0), (e.src = "https://www.google-analytics.com/analytics.js");
@md604
md604 / vue-section-quotes.js
Created January 16, 2021 16:01
QuotesApp (Vue 3.x edition)
import './vue-section-quotes.scss';
import Vue from 'vue';
import Quotes from './quotes.vue';
const { h } = Vue; // in Vue 3.x 'h' function is globaly imported
export class QuotesApp {
constructor(id, data) {
this._sectionId = id;
this._appType = 'vue-quotes';
this._appInstance = null;
@md604
md604 / shop_events_listener.js
Created January 9, 2021 17:47
Full file version
!(function () {
var e = function (e) {
var t = { exports: {} };
return e.call(t.exports, t, t.exports), t.exports;
},
s = (function () {
function r(e, t) {
for (var n = 0; n < t.length; n++) {
var r = t[n];
(r.enumerable = r.enumerable || !1), (r.configurable = !0), "value" in r && (r.writable = !0), Object.defineProperty(e, r.key, r);
@md604
md604 / trekkie.min.js
Created January 9, 2021 17:45
Full file version
!(function () {
"use strict";
var e = {
693: function (e, t, n) {
var r,
o =
(this && this.__extends) ||
((r = function (e, t) {
return (r =
Object.setPrototypeOf ||
@md604
md604 / shop_events_listener.js
Created January 5, 2021 21:23
Lines 249-258
(n = XMLHttpRequest),
(r = n.prototype.open),
(a = n.prototype.send),
(n.prototype.open = function (e, t) {
(this._url = t), (this._method = e), o.handleXhrOpen(), r.apply(this, arguments);
}),
(n.prototype.send = function (e) {
var t = new o(this, this._url, this._method, e);
this.addEventListener ? this.addEventListener("readystatechange",
t.onReadyStateChange.bind(t), !1) : ((t.oldOnReadyStateChange = this.onreadystatechange),