Skip to content

Instantly share code, notes, and snippets.

View konosp's full-sized avatar

Konstantinos Papadopoulos konosp

  • Analyticsmayhem
View GitHub Profile
@konosp
konosp / p-value.ipynb
Last active March 13, 2021 13:43
Calculating p-value
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@konosp
konosp / adobeAnalyticsReportsOutput.md
Created June 14, 2020 11:21
Adobe Analytics v2 Reports - Data output
itemId_lvl_1 value_lvl_1 itemId_lvl_2 value_lvl_2 metrics/visits metrics/orders metrics/event1
0 Other 1 Paid Search 233 39 10
0 Other 2 Natural Search 424 12 412
0 Other 3 Display 840 41 31
... ... ... ... ... ... ...
1728229488 Tablet 1 Paid Search 80 12 41
1728229488 Tablet 2 Natural Search 50 41 21
... ... ... ... ... ... ...
@konosp
konosp / adobeAnalyticsRequest.py
Created June 14, 2020 11:19
Adobe Analytics API v2 - Request example
from analytics.mayhem.adobe import analytics_client
ADOBE_ORG_ID = os.environ['ADOBE_ORG_ID']
SUBJECT_ACCOUNT = os.environ['SUBJECT_ACCOUNT']
CLIENT_ID = os.environ['CLIENT_ID']
CLIENT_SECRET = os.environ['CLIENT_SECRET']
PRIVATE_KEY_LOCATION = os.environ['PRIVATE_KEY_LOCATION']
ACCOUNT_ID = os.environ['ACCOUNT_ID']
REPORT_SUITE_ID = os.environ['REPORT_SUITE_ID']
@konosp
konosp / report-object.json
Last active October 4, 2021 11:08
Adobe Analytics v2 API
{
"rsid":"adbedocrsid",
"globalFilters":[
{
"type":"dateRange",
"dateRange":"2017-12-31T00:00:00.000/2018-01-06T23:59:59.999"
}
],
"metricContainer":{
"metrics":[
@konosp
konosp / createTable.sql
Created February 16, 2020 15:10
BigQuery DML Merge Sample
CREATE OR REPLACE TABLE `<project id>`.`<dataset id>`.`test`
OPTIONS() AS( SELECT 'a' AS id, '1' AS value );
@konosp
konosp / profile.yml
Last active January 10, 2020 22:03
Adobe Analytics Clickstream & dbt Models
adobe-clickstream-bigquery:
target: local-dev
outputs:
local-dev:
type: bigquery
method: oauth
project: <project name>
dataset: adobe_analytics_dbt_posts
threads: 1
timeout_seconds: 300
@konosp
konosp / identifyChannel.js
Last active December 2, 2019 10:41
Identify the marketing channel based referring domain information
// channel_domain_mapping
var DOMAINS_NATURAL_SEARCH = ['www.google.', 'bing.',
'search.yahoo.', '.yandex.'];
var DOMAINS_NATURAL_SOCIAL = ['facebook.com', 't.co', 'pinterest.', 'linkedin.com',
'plus.google','instagram.com'];
var DOMAINS_REFERRING = ['.paypal.com','www.my-bank.com'];
// Returns an array with the channel_id and the referring domain
function identifyChannel( channel_id , channel_domain_mapping , referrer) {
if (referrer && referrer !== '') {
@konosp
konosp / isChannelClickthrough.js
Last active November 25, 2019 16:52
Identify if a Marketing Channel Clickthrough was performed
function isChannelClickthrough(channel_parameter, referrer) {
// Tealium-specific variable to identify first hit of session.
var session_hit_number = b.tealium_session_event_number;
// If channel_parameter is present, paid channel click-through occured
if (channel_parameter && channel_parameter !== '')
return true;
else if (referrer && referrer !== '') {
if (identifyChannels(NATURAL_SEARCH, DOMAINS_NATURAL_SEARCH, referrer)
|| identifyChannels(NATURAL_SOCIAL, DOMAINS_NATURAL_SOCIAL, referrer)
|| identifyChannels(REFERRING_DOMAIN, DOMAINS_REFERRING, referrer))
-- This query is not valid as there is no realtime data available in the sample data set.
SELECT
date AS Date,
channelGrouping AS Default_Channel_Grouping,
Sessions
FROM (
SELECT
date,
CASE
WHEN trafficSource.source = '(direct)' AND (trafficSource.medium = '(not set)' OR trafficSource.medium = '(none)') THEN 'Direct'