Skip to content

Instantly share code, notes, and snippets.

View robhammond's full-sized avatar

Rob Hammond robhammond

View GitHub Profile
@robhammond
robhammond / Custom Medium - Data Studio.js
Created July 10, 2018 08:38
Custom Acquisition channel - Data Studio
CASE
WHEN ((Source="direct" AND Medium="(not set)") OR Medium="(none)") THEN "Direct"
WHEN Medium="organic" THEN "Organic Search"
WHEN (Social Source Referral="Yes" OR REGEXP_MATCH(Medium,"^(social|social-network|social-media|sm|social network|social media)$")) OR REGEXP_MATCH(Source,"(facebook|t.co|reddit|fark|linkedin|pinterest)") THEN "Social"
WHEN Medium="email" THEN "Email"
WHEN Medium="referral" and not(REGEXP_MATCH(Source,"(facebook|t.co|reddit|fark|linkedin|pinterest)") ) THEN "Referral"
ELSE "(Other)"
END
@robhammond
robhammond / Custom Country - Data Studio.js
Created July 10, 2018 08:59
Custom Country - Data Studio dimension
CASE
WHEN (country="United Kingdom") THEN "UK"
WHEN (country="United States") THEN "USA"
WHEN (country="India") THEN "India"
WHEN (country="Ireland") THEN "Ireland"
ELSE "(Other)"
END
@robhammond
robhammond / Custom Page Type - Data Studio.js
Last active July 10, 2018 11:23
Custom Page Type Dimension - Data Studio
CASE
WHEN (REGEXP_MATCH(Page/Screen Path (Clean),".*?/all-about/.*?")) THEN "Topic"
WHEN (REGEXP_MATCH(Page/Screen Path (Clean),".*?-[0-9]+$")) THEN "Article"
WHEN (REGEXP_MATCH(Page/Screen Path (Clean),"^https?://[^/]+/.*?/$")) THEN "Section"
WHEN (REGEXP_MATCH(Page/Screen Path (Clean),"^https?://[^/]+/$")) THEN "Home"
ELSE "(Other)"
END
@robhammond
robhammond / Custom Site Groupings - Data Studio.js
Last active August 6, 2018 16:49
Custom Site Groupings dimension - Data Studio
CASE
WHEN (REGEXP_MATCH(Page/Screen Path (Clean),".*?(mirror.co.uk|dailyrecord.co.uk|irishmirror.ie|insider.co.uk|belfastlive|glasgowlive|dublinlive|rsvplive.ie).*$")) THEN "Nationals"
WHEN (REGEXP_MATCH(Page/Screen Path (Clean),".*?(manchestereveningnews.co.uk|liverpoolecho.co.uk|walesonline|birminghammail|chroniclelive|bristolpost|hulldailymail|nottinghampost|plymouthherald|leicestermercury).*$")) THEN "Regional Capitals"
WHEN (REGEXP_MATCH(Page/Screen Path (Clean),".*?(derbytelegraph|gazettelive|stokesentinel|coventrytelegraph|examiner|cambridge-news|grimsbytelegraph|chesterchronicle|leeds-live|getwestlondon|burtonmail|scunthorpetelegraph).*$")) THEN "Urban Hub"
WHEN (REGEXP_MATCH(Page/Screen Path (Clean),".*?(croydonadvertiser|hertfordshiremercury|birminghampost|macclesfield-express|crewechronicle|rossendalefreepress|accringtonobserver|loughboroughecho|hinckleytimes).*$")) THEN "Community Sites"
WHEN (REGEXP_MATCH(Page/Screen Path (Clean),".*?(dailypost|devonlive|gloucestershirelive|getsurrey|somerse