Skip to content

Instantly share code, notes, and snippets.

View kmclaugh's full-sized avatar

Kevin McLaughlin kmclaugh

View GitHub Profile
@kmclaugh
kmclaugh / calendly-conversion.json
Created January 4, 2024 16:30
GTM Recipe for Calendly Conversion Tracking with Segment
{
"exportFormatVersion": 2,
"exportTime": "2024-01-04 16:27:54",
"containerVersion": {
"path": "accounts/6004616452/containers/116024490/versions/0",
"accountId": "6004616452",
"containerId": "116024490",
"containerVersionId": "0",
"container": {
"path": "accounts/6004616452/containers/116024490",
@kmclaugh
kmclaugh / shopify-custom-pixel-logger.json
Last active August 31, 2023 21:23
Shopify Custom Pixel GTM Logger
{
"exportFormatVersion": 2,
"exportTime": "2023-08-31 21:22:41",
"containerVersion": {
"path": "accounts/4701996609/containers/164567808/versions/0",
"accountId": "4701996609",
"containerId": "164567808",
"containerVersionId": "0",
"container": {
"path": "accounts/4701996609/containers/164567808",
// On login
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
'event': 'login', // constant
'partnerName': 'Intuit',
'partnerId': 123,
'user_id: '24073'
});
// On signup
@kmclaugh
kmclaugh / gumroad-gtm.html
Created February 6, 2023 18:08
Gumroad GTM
<!-- Google Tag Manager -->
<script>(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://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-PF7D9F9');</script>
<!-- End Google Tag Manager -->
<script>
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
@kmclaugh
kmclaugh / atwave-shopify-thankyou.liquid
Created October 11, 2022 14:36
Atwave purcahse pixel on Shopify confirmation page additional scripts
{% if first_time_accessed %}
<script>
// Require the necessary APIs
var logToConsole = console.log;
var log = logToConsole;
var localStorage = window.localStorage;
getCookie = function (name) {
var match = document.cookie.match(new RegExp("(^| )" + name + "=([^;]+)"));
if (match) return match[2];
@kmclaugh
kmclaugh / data-studio-jwt.js
Created May 20, 2022 19:31
Use JSON Web Token (jwt) in Google Data Studio
/*
* based on https://www.labnol.org/code/json-web-token-201128
* Use https://jwt.io/#debugger-io to verify
*/
function createJwt(privateKey, expiresInHours, data) {
// Sign token using HMAC with SHA-256 algorithm
const header = {
alg: "HS256",
typ: "JWT",
@kmclaugh
kmclaugh / handler.js
Last active March 7, 2022 15:49
segment click tracking handler
import { eventObserver } from 'ui-event-observer'
const clickHandler = (event) => {
const {
target: { href, innerText, dataset },
} = event
if (dataset && dataset.action) {
const { object, action } = dataset
const eventName = `${object} ${action}`
track(eventName, {
@kmclaugh
kmclaugh / README.md
Last active February 3, 2022 16:03
Shopify Buy Buttons - Thank You Page

Go to Settings > Checkout > Attional Scripts > Order status page.

Fill in YOUR CONTAINER ID

@kmclaugh
kmclaugh / products-array.js
Last active January 18, 2022 17:35
How to update the products array.
/*
* description: You need to update the products array to change the id field
* from the product id to the product sku so it matches the checkout experience.
* See the example product detail event below.
*/
{
event: "view_item_ua",
ecommerce: {
detail: {
@kmclaugh
kmclaugh / signed-up.js
Last active January 11, 2022 15:21
Cleeng.com Account Signup
/*
* action: signup
* description: fire whenever a new user signs up for the first time (ie creates an account)
* notes: fill in the necessary information in brackets {{}}
*/
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: "User Signed Up",
userId: "{{userId}}", // The user id
emailAddress: "{{emailAddress}}", // The user's email address