From 48b8b541792844aa3772300b0cb8ee9a1f602b34 Mon Sep 17 00:00:00 2001 From: nkalupahana Date: Tue, 6 Feb 2024 20:54:19 -0600 Subject: [PATCH] Add first-party tracking system to blog --- Gemfile | 5 ++++- Gemfile.lock | 6 ++++++ _layouts/home.html | 7 +++++++ _layouts/post.html | 6 ++++++ 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index fe9211f..ef18f1e 100644 --- a/Gemfile +++ b/Gemfile @@ -7,4 +7,7 @@ gem "jekyll-feed", "~> 0.9" gem "jekyll-seo-tag", "~> 2.1", git: "https://github.com/nkalupahana/jekyll-seo-tag" gem "kramdown-parser-gfm" if ENV["JEKYLL_VERSION"] == "~> 3.9" gem "jekyll-toc" -gem "jekyll-sitemap" \ No newline at end of file +gem "jekyll-sitemap" +gem "csv" +gem "base64" +gem "bigdecimal" \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index a10f72d..97a6b1b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -10,8 +10,11 @@ GEM specs: addressable (2.8.6) public_suffix (>= 2.0.2, < 6.0) + base64 (0.2.0) + bigdecimal (3.1.5) colorator (1.1.0) concurrent-ruby (1.2.3) + csv (3.2.8) em-websocket (0.5.3) eventmachine (>= 0.12.9) http_parser.rb (~> 0) @@ -86,6 +89,9 @@ PLATFORMS x86_64-linux DEPENDENCIES + base64 + bigdecimal + csv jekyll (>= 3.5, < 5.0) jekyll-feed (~> 0.9) jekyll-seo-tag (~> 2.1)! diff --git a/_layouts/home.html b/_layouts/home.html index c24933b..ef8bdc8 100644 --- a/_layouts/home.html +++ b/_layouts/home.html @@ -203,6 +203,13 @@

Ready to get started?

utm_campaign = params.get("utm_campaign"); } + const lssource = localStorage.getItem("utm_source"); + const lscampaign = localStorage.getItem("utm_campaign"); + if (lssource && lscampaign) { + utm_source = lssource; + utm_campaign = lscampaign; + } + for (const el of document.getElementsByClassName("appStoreLink")) { el.onclick = () => { sendInstallRequest(); diff --git a/_layouts/post.html b/_layouts/post.html index b7cfcff..6eddb93 100644 --- a/_layouts/post.html +++ b/_layouts/post.html @@ -108,4 +108,10 @@ document.addEventListener("DOMContentLoaded", function(e) { Scroller.init(); }) +const source = localStorage.getItem("utm_source"); +const campaign = localStorage.getItem("utm_campaign"); +if (!source && !campaign) { + localStorage.setItem("utm_source", "blog"); + localStorage.setItem("utm_campaign", '{{ page.title | downcase | split: " " | join: "_"}}'); +} \ No newline at end of file