Skip to content

Instantly share code, notes, and snippets.

@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 / 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_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 / 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 / adobe_launch_ajax_listener_trigger().js
Last active October 9, 2019 19:42
thanks to @StewartSchilling for helping me get this figured out
_satellite.logger.log("CHECKING JQUERY", $, jQuery);
$(document).ready(function() {
_satellite.logger.log("INSTALLING HANDLER");
$(document).ajaxSuccess(function(event, xhr, settings) {
_satellite.logger.log("FIRING HANDLER", event, xhr, settings);
var alreadyRun = false;
console.log("already run false");
if ((settings.url.indexOf("/loadResults.jsp") > -1) && (alreadyRun = false)); {
_satellite.logger.log("HANDLER CAUGHT loadResults.jsp", event, xhr, settings);
alreadyRun = true;
@ryanpraski
ryanpraski / drift_google_tag_manager_data_layer_event_listener.js
Last active September 26, 2019 16:17
drift google tag manager gtm dataLayer event listeners for chat widget including playbook interactions and meeting bookings
<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
});
@ryanpraski
ryanpraski / previous_pageName_session_storage
Created August 28, 2018 15:02
If you want to save the previous pageName via DTM without a Plugin (getPreviousValue), you can use Session Storage. Two Pageload Rules are needed.
[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") {
@ryanpraski
ryanpraski / google_analytics_api_app_script.js
Created August 9, 2018 18:22 — forked from dcvogi/top5pages.js
Queries the data for the top 5 pages of the website.
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);
@ryanpraski
ryanpraski / drift_api_R_query.R
Last active January 15, 2018 05:35
drift_api_query_with_R
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'))
@ryanpraski
ryanpraski / adobe_analytics_automatic_link_download_tracking
Created December 6, 2017 23:34
Adobe Analytics Automatic Link and Download Tracking Functions