This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// LZW-compress a string | |
function lzw_encode(s) { | |
var dict = {}; | |
var data = (s + "").split(""); | |
var out = []; | |
var currChar; | |
var phrase = data[0]; | |
var code = 256; | |
for (var i=1; i<data.length; i++) { | |
currChar=data[i]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/******************************* | |
* Automatically adds any new keywords in your | |
* Alpha campaigns as exact match negatives in | |
* the corresponding Beta campaign. Also handles | |
* pausing or removing keywords in your Alpha campaign | |
* and removing the corresponding negative in your Beta. | |
*******************************/ | |
// Just as before, these strings will be | |
// used to identify your Alpha and Beta campaigns. | |
// This script assumes that your Alpha campaigns are |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Generates a client ID in the format historically used by the Google Analytics | |
* JavaScript libraries. Note that any alphanumeric value may be used, but | |
* ideally each should be unique to a given client. | |
* | |
* More information on Client IDs: | |
* https://developers.google.com/analytics/devguides/collection/protocol/v1/email#client-id-cid | |
*/ | |
function generateGaClientId() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH | |
events AS ( | |
SELECT | |
TIMESTAMP_MICROS(event_timestamp) AS event_ts, | |
CONCAT(user_pseudo_id,'-',event_name,'-',CAST(event_timestamp AS STRING)) AS event_id, | |
user_pseudo_id AS user_pseudo_id, | |
user_id, | |
traffic_source.name AS utm_channel, | |
traffic_source.medium AS utm_medium, | |
traffic_source.source AS utm_source, |