Skip to content

Instantly share code, notes, and snippets.

View fljoly's full-sized avatar

François fljoly

View GitHub Profile
@zjuul
zjuul / sql_data_viz.sql
Last active April 10, 2025 02:48
Data visualisation in SQL
-- this query outputs a data visualisation to explore how many unique products people
-- see on your website, and the conversion rate
-- it uses Big Query SQL on a GA4Dataform events table - check https://github.com/superformlabs/ga4dataform-community
with products_per_user as (
SELECT
user_pseudo_id,
count( distinct if(event_name = 'view_item', i.item_name, NULL) ) as n_items_viewed,
max( if(event_name = 'purchase', 1, 0)) as purchaser
library(googleAuthR)
library(googleAnalyticsR)
library(tidyverse)
library(bigQueryR)
library(rvest)
library(lubridate)
# Last Financial Week
end_date <- floor_date(Sys.Date(),"week") - 1
start_date <- end_date - 6
@hitGovernor
hitGovernor / getHotJarUserID.js
Last active April 12, 2023 11:17
Retrieves the HotJar user ID from the browser. The ID can be passed to analytics or other systems as a way to connect HotJar recordings to other systems.
(function () {
// gets hotjar user id (hjUID)
var hjUID = "";
try {
if (typeof (hj) != "undefined" && hj.hasOwnProperty("globals")) {
// sample: a21c0a02-3b48-53c6-94b4-5604e281e5d8
// the value before the first "-" ("a21c0a02") is the user identifier that can be referenced in the hj interface
// use the following snippet to return only the user identifier (eg// "a21c0a02"):
// hjUID =hj.globals.get("userId").split("-").shift();
/**
* Unpivot a pivot table of any size.
*
* @param {A1:D30} data The pivot table.
* @param {1} fixColumns Number of columns, after which pivoted values begin. Default 1.
* @param {1} fixRows Number of rows (1 or 2), after which pivoted values begin. Default 1.
* @param {"city"} titlePivot The title of horizontal pivot values. Default "column".
* @param {"distance"[,...]} titleValue The title of pivot table values. Default "value".
* @return The unpivoted table
* @customfunction
@pshapiro
pshapiro / CausalImpact.ipynb
Last active March 4, 2024 14:15
CausalImpact implementation in Python to demonstrate SEO A/B Testing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@iconifyit
iconifyit / htaccess-ab-test
Last active May 27, 2025 12:50
A/B Testing with htaccess
# ############################### #
# A/B TESTING (START) #
# ############################### #
# (1) Check if our cookie is already set.
# If so, redirect to the previously-viewed page.
RewriteCond %{HTTP_COOKIE} ab_test_vers=([^;]+)
RewriteRule ^THE-PAGE-BEING-TESTED$ HTTP://YOUR-DOMAIN.COM/tracking/%1 [cookie=ab_test_vers_match:true:YOUR-DOMAIN.COM,L]
@rudeboybert
rudeboybert / modeling_with_data_tidyverse.R
Last active October 15, 2025 17:24
R source code for "Modeling with Data in the Tidyverse" DataCamp course
# R source code for all slides/videos in Albert Y. Kim's "Modeling with Data in
# the Tidyverse" DataCamp course:
# https://www.datacamp.com/courses/modeling-with-data-in-the-tidyverse
# This code is available at http://bit.ly/modeling_tidyverse
# Load all necessary packages -----
library(ggplot2)
library(dplyr)
library(moderndive)
@pshapiro
pshapiro / internal-pagerank.r
Last active March 29, 2023 16:36
Calculate Internal PageRank from Screaming Frog Crawl
library("igraph")
# Swap out path to your Screaming Frog All Outlink CSV. For Windows, remember to change backslashes to forward slashes.
links <- read.csv("C:/Documents/screaming-frog-all-outlinks.csv", skip = 1) # CSV Path
# This line of code is optional. It filters out JavaScript, CSS, and Images. Technically you should keep them in there.
links <- subset(links, Type=="AHREF") # Optional line. Filter.
links <- subset(links, Follow=="true")
links <- subset(links, select=c(Source,Destination))
g <- graph.data.frame(links)
pr <- page.rank(g, algo = "prpack", vids = V(g), directed = TRUE, damping = 0.85)
values <- data.frame(pr$vector)
@derekmartinla
derekmartinla / amazon-autocomplete
Last active December 12, 2023 04:56
Leverage Amazon To Find High Commercial Intent Keywords
/**********************************************************************************************************************
* Amazon Autocomplete Tool
* Leverage the Amazon Autocomplete feature to find highly commercial keyword opportunities.
* Export the results for efficient importing into Google Adwords
* Version 1.0
* Created By: Derek Martin
* DerekMartinLA.com or MixedMarketingArtist.com
**********************************************************************************************************************/
var hashMapResults = {};
@dmarx
dmarx / scrape_reddit_w_R.r
Last active September 8, 2022 09:51
Demo code showing how to collect analyze the subreddits a particular user has participated in, using R sintead of python (praw). I don't believe the code is exiting when it should, but this should at least serve as a jumping off point from the person who asked for help: http://www.reddit.com/r/rstats/comments/1tq4au/accessing_the_reddit_api_thro…
#install.packages("rjson","RCurl")
library(RCurl)
library(rjson)
get_User_subs_page = function(user, after=NULL, cache=c()){
baseurl = "http://www.reddit.com/user/"
params = "limit=100"
if(!is.null(after)){
params = paste(params, "&after=",after, sep="")