Skip to content

Instantly share code, notes, and snippets.

View stanasiukcom's full-sized avatar

Maciek Stanasiuk stanasiukcom

View GitHub Profile
@stanasiukcom
stanasiukcom / Form Abandonment Tracking
Last active May 11, 2018 01:42
Form Abandonment Tracking Script for Adobe Analytics (SiteCatalyst)
var formTrackingModule = (function($){
var config = {
inputTypesTracking : ["text", "radio", "checkbox"],
inputEventsTracking : ["focus", "blur"],
timeTracking : true,
ConsoleLogging : true,
focusCounter : true,
mapper : {
lastFocusName : 'eVar20',
WITH user_cart_journeys AS (
SELECT
user_pseudo_id
,event_timestamp
,event_name
,RANK() OVER (PARTITION BY user_pseudo_id ORDER BY event_timestamp) AS rank
FROM
`bigquery-public-data.ga4_obfuscated_sample_ecommerce.events_*`
WHERE
_TABLE_SUFFIX BETWEEN '20210101' AND '20210131'
WITH unnestedHits AS (
SELECT
fullVisitorId
,visitId
,visitStartTime
,h.*
FROM
`bigquery-public-data.google_analytics_sample.ga_sessions_20170801`
,UNNEST(hits) AS h
)
import imp
import requests
import jwt
from datetime import datetime, timedelta
from google.cloud import bigquery
import pandas as pd
import base64
import json
def main(event, context):
// Payments
created,available_on,currency,gross,fee,net,reporting_category,description
// Subscriptions
id,customer,start_date,cancel_at,amount,currency
// Load Day.js
eval(UrlFetchApp.fetch('https://unpkg.com/[email protected]/dayjs.min.js').getContentText());
eval(UrlFetchApp.fetch('https://unpkg.com/[email protected]/locale/pl.js').getContentText());
dayjs.locale('pl')
eval(UrlFetchApp.fetch('https://unpkg.com/[email protected]/plugin/weekday.js').getContentText());
dayjs.extend(dayjs_plugin_weekday)
eval(UrlFetchApp.fetch('https://unpkg.com/[email protected]/plugin/utc.js').getContentText());
dayjs.extend(dayjs_plugin_utc)
var config = {
function runQuery() {
// Replace this value with the project ID listed in the Google
// Cloud Platform project.
const projectId = '';
const request = {
query: 'WITH lastSunday AS (SELECT CASE WHEN EXTRACT(DAYOFWEEK FROM CURRENT_DATE()) = 1 THEN DATE_SUB(CURRENT_DATE(),INTERVAL 3 DAY) ELSE DATE_SUB(CURRENT_DATE(), INTERVAL 7 DAY) END AS d)' +
'SELECT Date, Package_Name, Product_ID, Country, New_Subscriptions, Cancelled_Subscriptions, Active_Subscriptions, _LATEST_DATE, _DATA_DATE FROM `` WHERE Date BETWEEN DATE_TRUNC((SELECT d FROM lastSunday), WEEK(MONDAY)) AND DATE_TRUNC(CURRENT_DATE(), WEEK(SUNDAY)) ORDER BY Date DESC',
useLegacySql: false
};
function forEachRangeCell(range, f) {
const numRows = range.getNumRows();
const numCols = range.getNumColumns();
for (let i = 1; i <= numCols; i++) {
for (let j = 1; j <= numRows; j++) {
const cell = range.getCell(j, i)
f(cell)
}