Skip to content

Instantly share code, notes, and snippets.

@ryanpraski
ryanpraski / zendesk_tracking_adobe_launch_gtm.js
Last active October 28, 2019 20:29
Zendesk chat formerly know as Zopim chat connected, chat start, chat end tracking in Adobe Launch and Google Tag Manager (GTM). See more events for the chat api here: https://api.zopim.com/files/meshim/widget/controllers/LiveChatAPI-js.html
try {
$(document).ready(function() {
if (typeof zE != 'undefined') {
zE(function() {
$zopim(function() {
$zopim.livechat.setOnConnected(function() {
//console.log("zendesk chat connected");
//trigger();
_satellite.track('zendeskChatConnected');
dataLayer.push({
@ryanpraski
ryanpraski / salesforce_adwords_google_analytics_integration_web-to-lead_form_example.html
Last active January 8, 2020 23:09
Sample Salesforce web-to-lead form that captures Adwords GCLID in a hidden form field & Google Analytics Visitor ID in another hidden form field. Make sure to replace xxxxx, yyyyy, zzzzz with your specific Salesforce field values. Include your Google Analytics Tracking ID. Create a User Scope custom dimension in your Google Analytics property Ad…
<!DOCTYPE html>
<html>
<head>
<META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8">
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
@ryanpraski
ryanpraski / googleAnalyticsReporting.gs
Created July 30, 2017 01:37 — forked from chipoglesby/googleAnalyticsReporting.gs
Send your Google Analytics metrics and dimensions to Google Big Query using Google Apps Script.
//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");
@ryanpraski
ryanpraski / salesforce_adwords_integration_web-to-lead_form_example.html
Last active December 16, 2020 14:00
Sample Salesforce web-to-lead form that captures Adwords GCLID in a hidden form field. Make sure to replace xxxxx and yyyyy with your specific Salesforce field values.
<!DOCTYPE html>
<html>
<head>
<META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8">
</head>
<body>
<form action="https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" method="POST">
<script>
@ryanpraski
ryanpraski / costdata.gs
Last active January 19, 2021 17:03 — forked from chipoglesby/costdata.gs
Cost Data Upload via Google Analytic's Management API with Google Sheets
function uploadData() {
var accountId = "xxxxxxxx";
var webPropertyId = "UA-xxxxxxxx-x";
var customDataSourceId = "xxxxxxxx";
var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var maxRows = ss.getLastRow();
var maxColumns = ss.getLastColumn();
var data = [];
for (var i = 1; i <= maxRows; i++) {
data.push(ss.getRange([i], 1, 1, maxColumns).getValues());
library(googleAnalyticsR)
library(ggplot2)
#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 the Google Analytics Management API to see a list of Google Analytics accounts you have access to
my_accounts <- google_analytics_account_list()
View(my_accounts)
@ryanpraski
ryanpraski / pageScrollDepth.R
Last active March 18, 2021 06:54
Google Analytics scroll depth tracking report using the googleAnalyticsR & tidyr package. Check out this blog post tutorial on how to use this script: http://www.ryanpraski.com/scroll-depth-tracking-analysis-with-google-analytics-r/
library(googleAnalyticsR)
library(tidyr)
#Authorized Google Analytics R- this will open a webpage
#You must be logged into your Google Analytics account on your web browser
ga_auth()
#Use the Google Analytics Management API to see a list of Google Analytics accounts you have access to
my_accounts <- google_analytics_account_list()
View(my_accounts)
@ryanpraski
ryanpraski / google_search_console_daily.R
Last active April 27, 2021 06:49
Download Google Search Console data (formerly webmaster tools) to R using searchConsoleR package. This script downloads data for the most recent day of search console data which is 3 days ago. Tutorial describing how to automate daily Google Search Console pulls using this script: http://www.ryanpraski.com/google-search-console-api-r-guide-to-ge…
## A script to download and archive Google search console analytics (formerly webmaster tools)
##
## searchConsoleR package created by Mark Edmondson (http://markedmondson.me)
##
## This script downloads and writes data to .csv for the most recent day of search console data (3 days ago)
## load the required libraries
## (Download them with install.packages("googleAuthR") and install.packages("searchConsoleR") if necessary
library(googleAuthR)
library(searchConsoleR)
@ryanpraski
ryanpraski / pass_adobe_visitor_id_s_vi_cookie_cross_domain_in_query_parameter.js
Last active May 18, 2021 02:46
Pass the Adobe Analytics Visitor id s_vi cookie cross domain in a query parameter
@ryanpraski
ryanpraski / googleCloudSql_query_sheets_appscript.js
Created November 4, 2017 17:02
Google Cloud SQL Query in Sheets App Script
function connectToCloudSQL() {
var params = {
ip: "INSERT IP",
user: "INSERT USER",
password: "INSERT PASSWORD",
database: "INSERT DATABASE"
}
var dbUrl = 'jdbc:mysql://' + params.ip + '/' + params.database;