Skip to content

Instantly share code, notes, and snippets.

View IronistM's full-sized avatar
🏗️
Under construction

Manos Parzakonis IronistM

🏗️
Under construction
View GitHub Profile
SELECT
-- Default Channel Grouping (dimension)
CASE
WHEN trafficSource.source = '(direct)' AND (trafficSource.medium = '(not set)' OR trafficSource.medium = '(none)') THEN 'Direct'
WHEN trafficSource.medium = 'organic' THEN 'Organic Search'
WHEN hits.social.hasSocialSourceReferral = 'Yes' OR REGEXP_CONTAINS(trafficSource.medium, r'^(social|social-network|social-media|sm|social network|social media)$') THEN 'Social'
WHEN trafficSource.medium = 'email' THEN 'Email'
WHEN trafficSource.medium = 'affiliate' THEN 'Affiliates'
WHEN trafficSource.medium = 'referral' THEN 'Referral'
WHEN REGEXP_CONTAINS(trafficSource.medium, r'^(cpc|ppc|paidsearch)$') AND trafficSource.adwordsClickInfo.adNetworkType != 'Content' THEN 'Paid Search'
-- Some sample set custom dimensions return null values
SELECT
-- Custom Dimension XX (User)
(
SELECT
value
FROM
UNNEST(session.customDimensions)
WHERE
index = 3
const puppeteer = require('puppeteer')
const browser = await puppeteer.launch()
const page = await browser.newPage()
await page.goto('https://e-food.gr/')
const dl = JSON.parse(
await page.evaluate(() => JSON.stringify(window.dataLayer))
)
@sahava
sahava / dataLayerHistory.js
Last active March 13, 2024 12:26
JavaScript for persisting dataLayer array and data model composition across pages
(function() {
// Set the timeout for when the dataLayer history should be purged. The default is 30 minutes.
// The timeout needs to be in milliseconds.
var timeout = 30*60*1000;
// Change dataLayerName only if you've defined another named for the dataLayer array in your
// GTM container snippet.
var dataLayerName = 'dataLayer';
// Don't change anything below.
@cassiozen
cassiozen / pixelbook-dev-setup.md
Last active October 22, 2023 12:06 — forked from denolfe/pixelbook-linux-setup.md
Notes on setting up Pixelbook for development

Pixelbook Setup

Change your channel

Some of the features mentioned in this document only work on the beta or Dev channel. To change your channel:

  1. chrome://help in a browser window
  2. Click Detailed Build Information
  3. Change Channel
  4. Select Beta (Or Dev, if you're feeling adventurous)
@postman31
postman31 / GTM notifikator.gs
Created August 1, 2018 10:34
Notifies you about pending changes in your GTM workspaces by email
function myFunction() {
try {
var message = ''
var response = TagManager.Accounts.list()
response.account.map(function(account) {
Logger.log('fetching changes for %s', account.name)
var containers = TagManager.Accounts.Containers.list(account.path)
Utilities.sleep(5000)
if (!containers.container) {
Logger.log('no containers for %s', account.name)
@sahava
sahava / customTaskMonster
Last active August 6, 2020 20:58
One customTask to rule them all.
var _customTask = function () {
// customTask Builder by Simo Ahava
//
// More information about customTask: https://www.simoahava.com/analytics/customtask-the-guide/
//
// Change the default values for the settings below.
// clientIdIndex: The Custom Dimension index to where you want to send the visitor's Client ID.
// https://bit.ly/2Ms0ZcC
var clientIdIndex = 1;
@CarstVaartjes
CarstVaartjes / fb_prophet_chalice.py
Created April 8, 2018 19:24
fb-prophet transformation for aws lambda
# based on https://github.com/ryansb/sklearn-build-lambda
$ mkdir ~/.aws
$ cat >> ~/.aws/config
[default]
aws_access_key_id=YOUR_ACCESS_KEY_HERE
aws_secret_access_key=YOUR_SECRET_ACCESS_KEY
region=YOUR_REGION (such as us-west-2, us-west-1, etc)
@mhawksey
mhawksey / face-detection-to-google-analytics.py
Last active January 16, 2020 21:40
Snippet of code used for DevFest London 2017 to count faces in audience and send to Google Analytics (see https://mashe.hawksey.info/?p=17787)
import io
import picamera
import cv2
import numpy
def hitGA(faces):
print("Sending to GA")
requests.get("http://www.google-analytics.com/collect?v=1" \
+ "&tid=YOUR_UA_TRACKING_ID_HERE" \
+ "&cid=1111" \
@bearloga
bearloga / mkrproj.sh
Last active January 3, 2018 14:59
A bash shell script that can be used to turn the current directory into an RStudio project, opening the project in RStudio after creating it.
#!/bin/bash
# Usage: mkproj [projectname]
# projectname defaults to name of current directory
template="Version: 1.0\nRestoreWorkspace: Default\nSaveWorkspace: Default\nAlwaysSaveHistory: Default\n\nEnableCodeIndexing: Yes\nUseSpacesForTab: Yes\nNumSpacesForTab: 4\nEncoding: UTF-8\n\nRnwWeave: knitr\nLaTeX: pdfLaTeX"
wd=$(basename `pwd`)
if [ -z $1 ]; then