This file contains hidden or 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
/** | |
* Reverses the input url. | |
* | |
* EG: if the url is www.google.com, the result will be com.google.www - this is useful for sorting a sheet | |
* | |
* @param {string} input The url to reverse. | |
* @return The url reversed. | |
* @customfunction | |
*/ | |
function REVERSEURL(string) { |
This file contains hidden or 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
/** | |
* Get a query map based on a query string. | |
* | |
* The function will populate a map variable with key value pairs of the parameters. | |
* | |
* If there is more than one of the same key, the function will populate an array in the map with the multiple values within it | |
* | |
* @param {string} query The query string - the question mark is optional | |
* @return {object} key value pairs of the parameter / value of the parameter | |
*/ |
This file contains hidden or 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
/* | |
This code should be put directly after the ga create call, before any hits are fired to ensure | |
it captures all hits being sent to ga. | |
When any ga hit is fired, this code will capture it, fire the proper hit into GA and then forward | |
the hit query parameters to GTM via a dataLayer event. | |
The dataLayer event is called "gaHitTask" and the query parameters are sent in the "gaHitTaskParams" variable. | |
You can use code something similar to this: https://gist.github.com/MatthewDaniels/388fa1e0c02613f103f00a504ed58c55 |
This file contains hidden or 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
ga(function(tracker) { | |
// Grab a reference to the default sendHitTask function. | |
var originalSendHitTask = tracker.get('sendHitTask'); | |
// Modifies sendHitTask to send a copy of the request to a local server after | |
// sending the normal request to www.google-analytics.com/collect. | |
tracker.set('sendHitTask', function(model) { | |
// sends the original hit task |
This file contains hidden or 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 getSummary() { | |
var listed = Analytics.Management.AccountSummaries.list(); | |
var ss = SpreadsheetApp.getActiveSpreadsheet(); | |
var sheet = ss.getActiveSheet(); | |
// var baseRangeRow = 4 | |
// sheet.getRange(baseRangeRow,1).setValue(listed.items[0]); | |
// sheet.getRange(baseRangeRow+1,1).setValue(listed.items[0].webProperties[0]); | |
// sheet.getRange(baseRangeRow+2,1).setValue(listed.items[0].webProperties[0].profiles[0]); | |
This file contains hidden or 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
# Proxy Cache Settings | |
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=reverse_cache:60m inactive=90m max_size=1000m; |
This file contains hidden or 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
# Compression | |
# Enable Gzip compressed. | |
gzip on; | |
# Enable compression both for HTTP/1.0 and HTTP/1.1. | |
gzip_http_version 1.1; | |
# Compression level (1-9). | |
# 5 is a perfect compromise between size and cpu usage, offering about |
This file contains hidden or 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
if(window.ga) { | |
var arr = window.ga.getAll(); | |
for (var i = 0, len = arr.length; i < len; i++) { | |
var t = arr[i]; | |
if(console.group) { | |
console.group(t.get('name')); | |
} | |
console.log('Main tracker object:', t); |
This file contains hidden or 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 parseQueryString() { | |
var query = (window.location.search || '?').substr(1), | |
map = {}; | |
query.replace(/([^&=]+)=?([^&]*)(?:&+|$)/g, function(match, key, value) { | |
(map[key] = map[key] || []).push(value); | |
}); | |
return map; | |
} |
This file contains hidden or 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 request = new XMLHttpRequest(); | |
// if the endpoint changes, then manipulation of the returned data may need to change in the onReadyState handler | |
request.open('GET', 'https://api.ipify.org', true); | |
request.onreadystatechange = function() { | |
if (this.readyState === 4) { | |
if (this.status >= 200 && this.status < 400) { | |
// Success! | |
var data = this.responseText; | |
console.log('respose', data); |