Skip to content

Instantly share code, notes, and snippets.

@jrosell
jrosell / .htaccess
Created August 1, 2016 12:56 — forked from ScottPhillips/.htaccess
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@jrosell
jrosell / cleanEventAction.js
Created September 26, 2016 13:26
Remove emails from string in javascript (GTM)
function(){
return {{DLV - eventAction}}.replace(/([^.@\s]+)(\.[^.@\s]+)*@([^.@\s]+\.)+([^.@\s]+)/,"");
}
//Option A: Using User Agent & touch feature
function () {
var a = navigator.userAgent || navigator.vendor || window.opera;
if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)
@jrosell
jrosell / Make Exact Match Exact.js
Created October 31, 2017 10:11 — forked from BrainlabsDigital/Make Exact Match Exact.js
Adds negatives for any search query that doesn't actually *exactly* match an exact match keyword.
/**
*
* Make Exact Match Exact
*
* Adds negatives for any search query that doesn't actually exactly match an exact
* match keyword.
*
* Version: 2.0
* Google AdWords Script maintained on brainlabsdigital.com
*
@jrosell
jrosell / google_trends_query.js
Created November 24, 2017 19:57 — forked from hanxue/google_trends_query.js
Google Apps Script for querying Google trends
' Use it for fuzzy matching, clustering data and looking for duplicates.
Function JW(ByVal str1 As String, ByVal str2 As String) As Double
Dim l1, l2, lmin, lmax, m, i, j As Integer
Dim common As Integer
Dim tr As Double
Dim a1, a2 As String
l1 = Len(str1)
l2 = Len(str2)
If l1 > l2 Then
aux = l2
@jrosell
jrosell / uploadCostToGA.js
Last active January 26, 2018 16:24
Google Analytics Cost Data Import from Google Sheets automated using Google Apps Scripts.
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());
@jrosell
jrosell / amazon-autocomplete
Created April 5, 2018 07:54 — forked from derekmartinla/amazon-autocomplete
Leverage Amazon To Find High Commercial Intent Keywords
/**********************************************************************************************************************
* Amazon Autocomplete Tool
* Leverage the Amazon Autocomplete feature to find highly commercial keyword opportunities.
* Export the results for efficient importing into Google Adwords
* Version 1.0
* Created By: Derek Martin
* DerekMartinLA.com or MixedMarketingArtist.com
**********************************************************************************************************************/
var hashMapResults = {};
//-----------------------------------
// Authenticate and Connect to OAuth Service
// Created By: Russ Savage
// FreeAdWordsScripts.com
//-----------------------------------
function main() {
//Define the Twitter Keys and Secrets
//More info on obtaining these can be found at https://dev.twitter.com/docs/auth/tokens-devtwittercom
var oauth_key_stuff = {
"consumer_key" : "your consumer key",
/**
* This script exclude low performance Display placements with more than 1000 impressions AND no clicks AND no view through conversions AND no conversions
* (you can edit these values on the top level variables).
* If one of the placements detected is anonymous.google, the script doesn't exclude it
* Script saves all detected placements in a spreadsheet
* If the script execution is interrupted, it saves the last account executed and will start from that account at the next execution
*
* @author Alberto Esteves
* URL: http://www.albertoestevescorreia.com/adwords-script-eliminar-ubicaciones-display-bajo-rendimiento/
*