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
library(googleAnalyticsR) | |
library(ggplot2) | |
library(dplyr) | |
#Authorize Google Analytics R- this will open a webpage | |
#You must be logged into your Google Analytics account on your web browser | |
ga_auth() | |
#Use my_accounts to find the viewId. Make sure to replace this with your viewId. | |
my_id <- 94579701 |
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
library(dplyr) | |
library(ggplot2) | |
library(lubridate) | |
library(XML) | |
#load apple health export.xml file | |
xml <- xmlParse("C:\\Users\\praskry\\Desktop\\export_sleep.xml") | |
#transform xml file to data frame - select the Record rows from the xml file | |
df <- XML:::xmlAttrsToDataFrame(xml["//Record"]) |
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
//Replace xxx with your values as necessary. | |
function googleAnalyticsReporting() { | |
projectId = "xxx"; | |
datasetId = "xxx"; | |
tableId = 'xxx'; | |
data = []; | |
yesterday = new Date(); | |
yesterday.setDate(yesterday.getDate() - 1); | |
yesterday = Utilities.formatDate(yesterday, 'UTC', "yyyy-MM-dd"); |
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
function connectToCloudSQL() { | |
var params = { | |
ip: "INSERT IP", | |
user: "INSERT USER", | |
password: "INSERT PASSWORD", | |
database: "INSERT DATABASE" | |
} | |
var dbUrl = 'jdbc:mysql://' + params.ip + '/' + params.database; |
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
<script type="text/javascript"> | |
(function(dataLayer) { | |
var i = 0; | |
var jwpVideoIsPlaying = false; | |
//array of percentages at which progress notifications are pushed to the dataLayer | |
var markers = [10, 25, 50, 75, 90]; //adjust these values if you want different progress reports | |
var playersMarkers = []; | |
function findObjectIndexById(haystack, key, needle) { | |
for (var i = 0; i < haystack.length; 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
var isDownloadLink = function(lnk) { | |
var isDownload = false; | |
if (typeof lnk.href !== 'undefined') { | |
var fileTypes = window.s.linkDownloadFileTypes.split(','); | |
var href = lnk.href.toLowerCase(); | |
for (var k = 0; k < fileTypes.length; k++) { | |
if (href.indexOf(fileTypes[k].trim()) > -1) { | |
isDownload = true; | |
break; | |
} |
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
<script> | |
window.drift.on('ready',function(api){ | |
window.drift.on('message:sent',function(event){ | |
{ | |
dataLayer.push({ | |
'event': 'driftInteraction', | |
'eventCategory': 'drift', | |
'eventAction': 'message sent', | |
'eventLabel': 'drift>message sent conversation id: ' + event.conversationId | |
}); |
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
library(httr) | |
library(rjson) | |
url <-'https://driftapi.com/conversations/52662097/messages' | |
token <-'AQ14yXgTM934cMjNEGfa6epBDU6TpCIY' | |
query <- GET(url, add_headers('Authorization' = paste("bearer", token))) | |
http_status(query) | |
df <-fromJSON(content(query,type='text',encoding= 'UTF-8')) |
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
function main(){ | |
// Set up the parameters and variables | |
var sheetName = '<name>'; // The name of the sheet (not the Spreadsheet) we want to write the data e.g Sheet1 | |
var tableId = '<table id>'; // The id of the view to query the data from e.g ga:123456 | |
var startDate = 'yyyy-MM-dd'; // The start date of the query with the appropriate format e.g 2018-04-01 (1 April 2018) | |
var endDate = 'yyyy-MM-dd'; // The end date of the query with the appropriate format e.g 2018-04-30 (30 April 2018) | |
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet(); | |
var sheet = spreadsheet.getSheetByName(sheetName); |
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
[Adobe Analytics|DTM] Previous pageName | |
If you want to save the previous pageName via DTM without a Plugin (getPreviousValue), you can use Session Storage. Two Pageload Rules are needed. | |
First PLR: | |
- Trigger Rule at “DOM Ready” | |
- Rule Condition: Path “.*” (regex enabled) | |
- Custom Code “None-Sequential Javascript”: | |
if(typeof(Storage) != "undefined") { | |
if (typeof(s) !== "undefined") { |