Skip to content

Instantly share code, notes, and snippets.

Avatar

Martin Loetzsch martin-loetzsch

View GitHub Profile
View server-side-tracking-raw-event.json
{
"visitor_id": "10d1fa9c9fd39cff44c88bd551b1ab4dfe92b3da",
"session_id": "9tv1phlqkl5kchajmb9k2j2434",
"timestamp": "2018-12-16T16:03:04+00:00",
"ip": "92.195.48.163",
"url": "https://www.project-a.com/en/career/jobs/data-engineer-data-scientist-m-f-d-4072020002?gh_jid=4082751002&gh_src=9fcd30182&&utm_medium=social&utm_source=linkedin&utm_campaign=buffer",
"host": "www.project-a.com",
"path": [
"en",
"career",
View server-side-tracking-event-collector.php
<?php
require 'vendor/autoload.php';
// this cookie is set when not present
$cookieName = 'visitor';
// retrieve visitor id from cookie
$visitorId = array_key_exists($cookieName, $_COOKIE) ? $_COOKIE[$cookieName] : null;
View server-side-tracking-preprocessed-event.json
{
"visitor_id": "10d1fa9c9fd39cff44c88bd551b1ab4dfe92b3da",
"session_id": "9tv1phlqkl5kchajmb9k2j2434",
"timestamp": "2019-12-16T16:03:04+00:00",
"url": "https://www.project-a.com/en/career/jobs/data-engineer-data-scientist-m-f-d-4072020002?gh_jid=4082751002&gh_src=9fcd30182&&utm_medium=social&utm_source=linkedin&utm_campaign=buffer",
"host": "www.project-a.com",
"path": [
"en",
"career",
"jobs",
View server-side-tracking-lambda-function.py
import base64
import functools
import json
import geoip2.database
from google.cloud import bigquery
from ua_parser import user_agent_parser
@functools.lru_cache(maxsize=None)
View server-side-tracking-bigquery-example-query.sql
WITH
relevant_session AS (
SELECT
session_id,
timestamp
FROM
`pav-analytics.server_side_tracking.project_a_website_events`
WHERE
REGEXP_CONTAINS(url, '(?i)jobs/data-engineer-data-scientist')
AND device_brand != 'Spider')
View server-side-tracking-bigquery-example-output.txt
cat text/bigquery-example-query.sql | bq query --nouse_legacy_sql
Waiting on bqjob_r1213acb52d17011a_0000016cfc7967d0_1 ... (0s) Current status: DONE
+-----+------------------------------------------------------------------------------+
| n | url |
+-----+------------------------------------------------------------------------------+
| 109 | https://www.project-a.com/de/offline |
| 108 | https://www.project-a.com/en/offline |
| 93 | https://www.project-a.com/en |
| 36 | https://www.project-a.com/ |
| 34 | https://www.project-a.com/en/about-us/who-we-are |
@martin-loetzsch
martin-loetzsch / geometry.py
Created Oct 26, 2014
geometry.py: Conversions between WGS84, Cartesian, Mercator and TMS coordinates and bounding boxes
View geometry.py
"""geometry.py:
Conversions between WGS84, Cartesian, Mercator and TMS coordinates and bounding boxes,
useful for converting geographic view ports as generated by Google Earth to TMS bounding boxes
"""
import math
__author__ = "Martin Loetzsch"
__licence__ = "Apache 2.0"