Skip to content

Instantly share code, notes, and snippets.

@lambtron
lambtron / shopify.md
Last active October 23, 2023 17:48
segment event tracking for shopify
title sidebar
Segment Event Tracking for Shopify
Shopify

Segment makes it simple for Shopify merchants to integrate analytics, email marketing, advertising and optimization tools. Rather than installing all your tools individually, you just install Segment once. We collect your data, translate it, and route it to any tool you want to use with the flick of a switch. Using Segment as the single platform to manage and install your third-party services will save you time and money.

The guide below explains how to install Segment in your Shopify store. All you need to get up and running is copy and paste a few snippets of code into your theme editor. (You don't have to edit the code or be versed in JavaScript.) The following guide will show you how, step by step.


@lambtron
lambtron / utm_params_last_touch.html
Last active October 12, 2015 07:40
Tracking last_touch with UTM params
<script type="text/javascript">
function getQueryParam(url, param) {
param = param.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + param + "=([^&#]*)",
regex = new RegExp(regexS),
results = regex.exec(url);
if (results === null || (results && typeof(results[1]) !== 'string' && results[1].length)) {
return '';
} else {
return decodeURIComponent(results[1]).replace(/\+/g, ' ');
@lambtron
lambtron / sorter.js
Created October 20, 2015 17:27
Custom sort method for metalsmith-collections plugin in Segment's technical documentation.
/**
* Generate a custom sort method for given starting `order`. After the given
* order, it will ignore casing and put periods last. So for example a call of:
*
* sorter('Overview');
*
* That is passed:
*
* - Analytics.js
@lambtron
lambtron / la_vs_sf_yelp_scraper.py
Created November 2, 2018 21:44
LA vs. SF: which city has more diverse cuisine?
#
# Module dependencies.
#
import os
import csv
import itertools
import collections
from yelpapi import YelpAPI
@lambtron
lambtron / url_test.ts
Created March 29, 2022 01:58
Simple url test with `deno test`.
// url_test.ts
import { assertEquals } from "https://deno.land/std@0.132.0/testing/asserts.ts";
Deno.test("url test", () => {
const url = new URL("./foo.js", "https://deno.land/");
assertEquals(url.href, "https://deno.land/foo.js");
});
@lambtron
lambtron / css-in-deno.ts
Created January 24, 2023 21:14
console log css styles in deno
console.log(
"%cHello, %cworld!",
"text-decoration: underline",
"color: blue;"
);