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 dateRange = "THIS_MONTH"; | |
| var SPREADSHEET_URL = "url"; | |
| var accounts = []; | |
| var values = []; | |
| function main() { | |
| var ss = SpreadsheetApp.openByUrl(SPREADSHEET_URL); | |
| var clear = ss.getSheetByName('Adwords').getRange("A2:C").clear(); | |
| var sheet = ss.getSheetByName('Accounts'); | |
| var name = sheet.getName(); |
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
| <script> | |
| /*! | |
| * @preserve | |
| * jquery.scrolldepth.js | v0.4.1 | |
| * Copyright (c) 2014 Rob Flaherty (@robflaherty) | |
| * Licensed under the MIT and GPL licenses. | |
| */ | |
| ;(function ( $, window, document, undefined ) { | |
| "use strict"; |
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 SPREADSHEET_URL = ""; | |
| function facebookSpend() { | |
| var ss = SpreadsheetApp.openByUrl(SPREADSHEET_URL); | |
| var sheet = ss.getSheetByName('facebook'); | |
| var values = []; | |
| Utilities.sleep(1000); | |
| var fullUrl = 'https://graph.facebook.com/v2.3/act_xxx/stats?access_token=xxx'; | |
| var fetchRequest = UrlFetchApp.fetch(fullUrl); | |
| var results = JSON.parse(fetchRequest.getContentText()); | |
| Logger.log(results.spent/100); |
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
| <script> | |
| function ipAddresses() { | |
| var newIP = '{{visitorIP}}'; | |
| var patt = new RegExp("^28.28.128.1[0-9]?$"); | |
| if(patt.test(newIP) === true) {return('internal');} | |
| var patt = new RegExp("^65.65.65.12[0-9]?$"); | |
| if(patt.test(newIP) === true) {return('monitoring');} | |
| return('external'); | |
| } | |
| </script> |
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 getDirection(city1, city2) { | |
| var directions = Maps.newDirectionFinder() | |
| .setOrigin(city1).setDestination(city2) | |
| .setMode(Maps.DirectionFinder.Mode.DRIVING) | |
| .getDirections(); | |
| var d = directions.routes[0].legs[0].distance.text; | |
| return parseInt(d.split(" ")[0].replace(",", ""));; |
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 geocode_Addresses() { | |
| var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); | |
| var locationInfo = sheet.getRange(1, 1, sheet.getLastRow() - 1, 1).getValues(); | |
| var geoResults, lat, lng; | |
| for (var i = 0; i < locationInfo.length; i++) { | |
| geoResults = Maps.newGeocoder().geocode(locationInfo[i]); | |
| // Get the latitude and longitude | |
| lat = geoResults.results[0].geometry.location.lat; |
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 the Google Maps Link */ | |
| /* The longitude and latitude are passed as a comma separated string */ | |
| function getGoogleMapsLink(longLat) { | |
| return "https://maps.google.com/maps?q="+longLat; | |
| } | |
| /* Get the Postal Address from geo location */ | |
| function getStreetAddress(longLat) { | |
| var longLat = longLat.split(','); | |
| var response = Maps.newGeocoder().reverseGeocode(longLat[0], longLat[1]); |
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 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()); |
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 main() { | |
| var profileId = 'xxxxxxx'; | |
| // Dates should be in yyyy-mm-dd format. | |
| var startDate = 'yesterday'; | |
| var endDate = 'today'; | |
| var options = { | |
| 'dimensions': 'ga:source,ga:keyword', | |
| 'sort': '-ga:sessions,ga:source', | |
| 'filters': 'ga:medium==organic', |