Skip to content

Instantly share code, notes, and snippets.

View pwm1991's full-sized avatar
๐ŸŽˆ

Pete Martin pwm1991

๐ŸŽˆ
View GitHub Profile
// ==UserScript==
// @name Google Tag Manager improvements
// @namespace https://tagmanager.google.com
// @version 1
// @description Mostly makes GTM wider
// @author twitter.com/pwm1991
// @match tagmanager.google.com
// @grant none
// ==/UserScript==
// Query a JS Function with Args in a Tag
// Quote args even if not a string.
{{ Variable }}("{{ Varible }}")
// e.g.:
{{function parseFloat x100}}("{{transactionTotal}}")
// The variable needs to return a fn with the desired args:
@pwm1991
pwm1991 / export-csv
Created October 28, 2019 12:31
Export CSV macro, lazily.
Sub ExportCSV()
'
' ExportCSV Macro
'
'
Range("A1").Select
ChDir "\\rsnet.local\Users\UserData$\peterm\Downloads"
ActiveWorkbook.SaveAs Filename:= _
"\\rsnet.local\Users\UserData$\peterm\Downloads\export.csv" _
@pwm1991
pwm1991 / macro-word-autoformat
Created October 28, 2019 12:29
Word macro to make documents the way I like them
Sub AutoCorrect()
'
' AutoCorrect Macro
'
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = " "
.Replacement.Text = " "
@pwm1991
pwm1991 / metaKeywords.gtm
Created October 28, 2019 12:26
GTM - Function for logging meta keywords in a custom dimension. Removes generic phrases.
function() {
var keywords = document.head.querySelector("meta[name='keywords']").content.toLowerCase();
var removalPhrases =
[
"phrases to get rid of"
];
if (keywords.search != '') {
for (i = 0; i < removalPhrases.length; i++) {
phrase = removalPhrases[i];
@pwm1991
pwm1991 / cleanPageURL.gtm
Created October 28, 2019 12:23
GTM - removes crap from URLs. Inferior to a custom task.
// Removes URL paramters that are either a) useless or b) store personal data. This is a giant game of whack a mole.
function() {
var params = ['name','fname','lname','first','last','firstname','lastName','lastname','first+name','last+name','your+name','email','emailaddress','email+address','work+email+address'];
var a = document.createElement('a');
a.href = {{Page URL}};
if (a.search) {
qps = '&' + a.search.replace('?', '') + '&';
for (i = 0; i < params.length; i++) {