Skip to content

Instantly share code, notes, and snippets.

View cougrimes's full-sized avatar

Casey Grimes cougrimes

View GitHub Profile
@cougrimes
cougrimes / forms2-truncated
Last active August 29, 2015 14:13
Marketo Forms2.css Controlling Mobile Views
@media only screen and (max-width: 480px), only screen and (max-device-width: 480px), only screen and (max-device-height:480px){.mktoForm,.mktoForm *{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-moz-box-sizing:border-box;padding:10px}
.mktoForm .mktoGutter,.mktoForm .mktoOffset{display:none}
.mktoForm .mktoFormCol .mktoLabel{text-align:left;width:100%}
.mktoForm .mktoFormCol{float:none}
.mktoForm .mktoFieldWrap{float:none}
.mktoForm fieldset{padding:0 10px}
.mktoForm input[type=url],.mktoForm input[type=text],.mktoForm input[type=date],.mktoForm input[type=tel],.mktoForm input[type=email],.mktoForm input[type=number],.mktoForm textarea.mktoField,.mktoForm select.mktoField{width:100%;height:1.5em;line-height:1.5em;font-size:18px}
.mktoForm select.mktoField{height:auto}
.mktoForm .mktoFormRow .mktoField{clear:left}
.mktoForm .mktoFormRow .mktoFormCol{clear:both}
@cougrimes
cougrimes / ga-js-parameters.js
Last active August 29, 2015 14:13
Parse Google Analytics parameters as JS variables
var getURLParams = function() {
var temp = {};
document.location.search.replace(/\??(?:([^=]+)=([^&]*)&?)/g, function() {
var decode = function(s) {
return decodeURIComponent(s.split("+").join(" "));
};
temp[decode(arguments[1])] = decode(arguments[2]);
});
return temp;
};
@cougrimes
cougrimes / go-outside.js
Last active August 29, 2015 14:13
Force all links that are not localhost to have a blank target
$(document).ready(function () {
$.expr[':'].external = function (obj) {
return !obj.href.match(/^mailto\:/) && (obj.hostname != location.hostname) && !obj.href.match(/^javascript\:/) && !obj.href.match(/^$/)
};
$('a:external').attr('target', '_blank');
});
@cougrimes
cougrimes / marketo-country-iso.txt
Created June 17, 2015 22:31
Marketo Forms 2.0 ISO-3166 alpha-2 conversions for Country Fields
United States of America|US
Canada|CA
Afghanistan|AF
Åland Islands|AX
Albania|AL
Algeria|DZ
American Samoa|AS
Andorra|AD
Angola|AO
Anguilla|AI
@cougrimes
cougrimes / forms2-hiddennames.js
Last active August 29, 2015 14:24
Capture Marketo name values in alternate field in addition to primary (for allowing field-level block recordings.)
MktoForms2.loadForm("//app-xxx.marketo.com", "###-###-###", 1234, function (form) {
var vals = form.vals();
form.onValidate(function() {
if mktoPreFillFields.FirstName != vals.First || mkto.PreFillFields.LastName != vals.Last {
form.vals({"alternateFirst":vals.First, "alternateLast":vals.Last});
};
});
});
@cougrimes
cougrimes / override.css
Created July 16, 2015 21:34
Marketo Forms 2.0 mobile class reset
@media only screen and (max-width: 480px), only screen and (max-device-width: 480px), only screen and (max-device-height:480px){
.mktoForm,.mktoForm *{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-moz-box-sizing:border-box;padding:auto}
/* Yes, I know padding:auto isn't a real property - had to break things somehow :( */
.mktoLabel.mktoHasWidth {height: inherit !important;}
.mktoForm .mktoGutter,.mktoForm .mktoOffset{display:initial !important}
.mktoForm .mktoFormCol .mktoLabel{text-align:left;width:initial !important}
.mktoForm .mktoFormCol{float:initial !important}
.mktoForm .mktoFieldWrap{float:initial !important}
.mktoForm fieldset{padding:initial !important}
.mktoForm input[type=url],.mktoForm input[type=text],.mktoForm input[type=date],.mktoForm input[type=tel],.mktoForm input[type=email],.mktoForm input[type=number],.mktoForm textarea.mktoField,.mktoForm select.mktoField{width:100% !important;height:initial !important;line-height:initial !important;font-size:initial !i
@cougrimes
cougrimes / utm-parser-marketo.js
Last active November 8, 2022 14:36
UTM Parser for Marketo
//First, let's get the URI and have it split out all parameters
var getURLParams = function() {
var temp = {};
document.location.search.replace(/\??(?:([^=]+)=([^&]*)&?)/g, function() {
var decode = function(s) {
return decodeURIComponent(s.split("+").join(" "));
};
temp[decode(arguments[1])] = decode(arguments[2]);
});
@cougrimes
cougrimes / NormalizeMktoForms.css
Last active October 16, 2024 14:17
Marketo Form Normalizer--making things actually responsive.
.mktoForm, .mktoForm .mktoFieldWrap, .mktoForm .mktoHtmlText, .mktoForm input, .mktoLogicalField .mktoCheckboxList, .mktoRangeField, .mktoRangeValue {width:100% !important;}
@media only screen and (min-width:480px) {
.mktoFormCol:first-child:nth-last-child(2), .mktoFormCol:first-child:nth-last-child(2) ~ .mktoFormCol {width: 100% !important;}
.mktoFormCol:first-child:nth-last-child(3), .mktoFormCol:first-child:nth-last-child(3) ~ .mktoFormCol {width: 50% !important;}
.mktoFormCol:first-child:nth-last-child(4), .mktoFormCol:first-child:nth-last-child(4) ~ .mktoFormCol {width: 33.3333% !important;}
.mktoFormCol:first-child:nth-last-child(3) ~ .mktoFormCol {padding-left: 0.3em !important;}
}
@media only screen and (max-width:480px) {.mktoFormCol {width:100% !important;}}
.mktoAsterix{display:none !important;}
.mktoForm .mktoGutter {display:none !important;}
@cougrimes
cougrimes / mktoFormDebug.js
Created February 11, 2016 00:14
Have long forms? See where people give up.
var parentForm = document.querySelector("[id^=mktoForm_]");
parentForm.addEventListener("focusout", doSomething, false);
var formId = document.querySelectorAll('form.mktoForm')[0].getAttribute('id');
function doSomething(e) {
if (e.target !== e.currentTarget) {
var clickedItem = e.target.id;
ga('create', 'UA-XXXXXXXX-X');
ga('send','event','Marketo Form Fillout', formId, clickedItem)
}
{
"kind": "analytics#gaData",
"id": "https:\/\/www.googleapis.com\/analytics\/v3\/data\/ga?ids=ga:YYYYYYYYY&dimensions=ga:dimension1&metrics=ga:avgTimeOnPage&start-date=30daysAgo&end-date=yesterday",
"query": {
"start-date": "30daysAgo",
"end-date": "yesterday",
"ids": "ga:YYYYYYYYY",
"dimensions": "ga:dimension1",
"metrics": [
"ga:avgTimeOnPage"