Skip to content

Instantly share code, notes, and snippets.

<script>
/*
* adapted from https://developers.google.com/analytics/devguides/collection/analyticsjs/cross-domain#iframes
* I include the GA object reference in my script, so that one version of
* the script works whether served in an iFrame or on a standalone page.
* I usually have to rely on the 3rd-party vendor to implement the code, so
* I like to keep implementation as simple as possible.
*/
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
/**
* Writes a list of AdWords accounts in an MCC to a Google Sheet
* Useful in conjunction with scripts that run on batches of accounts
*
* The label-batching portion of this script was adapted from:
* http://magentosupport.help/knowledgebase/using-labels-to-executeinparallel-exceeding-the-50-account-limit/
*/
var TIMEZONE = 'MST';
var TODAY_STR = Utilities.formatDate(new Date(), TIMEZONE, 'yyyy-MM');
@nicobrx
nicobrx / to_util
Last active October 28, 2024 19:23
Google Apps Script utility functions for working with 2D arrays in Sheets/tabs, plus a few other miscellanea. The 2D functions depend on the first row of a tab being column headers and each row below the first row having the same number of columns as the first row.
/*
updated 2018-04-28
source lives here: https://gist.github.com/nicobrx/2ecd6fc9ca733dcd883afebba5cf200e
standalone script ID for use as a library: 1gZ78JObyrYiH0njoZ86fQ2NgMwavUgiXVhRDrIFetPZL256e31PSNiHq
Functions included here:
Sheets data array and object functions
objectifySheet(sheet,propertyNames,newPropertyNames) - Takes a sheet with a header row and converts it into an array of objects
arrayFromSheet(sheet,propertyNames,newPropertyNames) - creates an array from a sheet, can specify column headers
@nicobrx
nicobrx / adwords_report_scheduler.js
Created February 23, 2016 16:42
AdWords script - provides framework for scheduling reports in an MCC. Writes reports to a Google Sheet. Handles MCC limit of 50 accounts per script
/*
* written by Nico Brooks - www.twooctobers.com
* use at your own risk
*
* This script provides a generic framework for scheduling
* monthly AdWords reports and writing them to a Google sheet.
* To use, copy the script, set the global variables at the top of the file
* and customize the function getData. See
* https://developers.google.com/adwords/api/docs/guides/awql
* for reporting options