• Skip to main content
  • Skip to primary sidebar

PPC Scripts

by Lynt services

  • About the Author
  • PPC Services
  • Workshops for PPC companies
  • English
  • Czech
You are here: Home / Uncategorized / MCC script for controlling account performance and trends

MCC script for controlling account performance and trends

February 15, 2017 od Jakub Kašparů 2 Comments

This script is really great for daily overview of your account’s performance.

Key functions:

  1. ROAS trends for yesterday, 7 days, 30 days for each account.
  2. Color indication if performance(ROAS or CPA) does not meet set targets in each date range.
  3. Performance information for conversions, cost, and impression share metrics.
  4. View the most important performance metrics side by side over 3 different time periods.
  5. Linear prediction of your cost at the end of the month. You can set-up the configuration for ROAS and Cost in the Settings list.
  6. Uses MCC parallel function. You can process up to 100 accounts per run.

How to install script:

  1. Copy our template, input your Target ROAS and Budgets for each account in the Settings list.
  2. Insert the URL of your spreadsheet in line 1 of the script inside the brackets.
  3. Create a label in your MCC and then add the label to the accounts which you would like to see in the report.
  4. Put the name of your label on line 7 of the script after “CONTAINS” inside the brackets.
  5. Authorize script and set frequency to 1 hour.
  6. If you’d like to change the settings, just type the name of the account and change the cost of the target ROAS and it will be adjusted automatically.

Script for download
JavaScript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/* SETTINGS */
 
//Your own copy of our template - https://docs.google.com/spreadsheets/d/1yKcxyBJU-p5TIDaD3ynWENyGdlY6wHZs1CfLB4reUxQ/edit#gid=71729685
var SPREADSHEET_URL = "";
 
var SHEET_NAME = "Example";
var ACCOUNT_LABEL = "Lynt: eshop";
 
/* ------ */
 
function main() {
  
  MccApp.accounts().withCondition("LabelNames CONTAINS '"+ACCOUNT_LABEL+"'").withLimit(50).executeInParallel('processAccount', 'allFinished');
  
}
 
 
function getAccount(oneAccount) {
  
        var CurrentAccountNum = oneAccount.getCustomerId();
       var CurrentAccountName = oneAccount.getName();
      
        var data = GetData();
        
        var today = new Date();
        var MonthDays = [31,28,31,30,31,30,31,31,30,31,30,31];
    var thisMonthDays = MonthDays[today.getMonth()];
        var currentDays = today.getDate();
        
     var output = [
          CurrentAccountName,
          CurrentAccountNum,
          //ROAS
       _f(data['YESTERDAY'].AllConversionValue) / _f(data['YESTERDAY'].Cost),
       _f(data['LAST_7_DAYS'].AllConversionValue) / _f(data['LAST_7_DAYS'].Cost),
       _f(data['LAST_30_DAYS'].AllConversionValue) / _f(data['LAST_30_DAYS'].Cost),
          //ConversionValue
       _f(data['YESTERDAY'].AllConversionValue),
       _f(data['LAST_WEEK'].AllConversionValue),
       _f(data['THIS_MONTH'].AllConversionValue),
       _f(data['LAST_MONTH'].AllConversionValue),
          //Conversion
       _f(data['YESTERDAY'].AllConversions),
       _f(data['LAST_WEEK'].AllConversions),
       _f(data['THIS_MONTH'].AllConversions),
       _f(data['LAST_MONTH'].AllConversions),
            _f(data['LAST_14_DAYS'].AllConversions)-_f(data['LAST_7_DAYS'].AllConversions) ,
          //Cost
       _f(data['YESTERDAY'].Cost),
       _f(data['THIS_MONTH'].Cost),
       _f(data['LAST_MONTH'].Cost),
       _f(data['THIS_MONTH'].Cost) / (currentDays - 1) * thisMonthDays, //This month prediction
            _f(data['LAST_14_DAYS'].Cost)-_f(data['LAST_7_DAYS'].Cost) ,
          //Impression Share
       _fp(data['THIS_MONTH'].SearchImpressionShare),
       _fp(data['THIS_MONTH'].SearchRankLostImpressionShare),
       _fp(data['THIS_MONTH'].SearchBudgetLostImpressionShare),
       _fp(data['THIS_MONTH'].ContentImpressionShare),
       _fp(data['THIS_MONTH'].ContentRankLostImpressionShare),
       _fp(data['THIS_MONTH'].ContentBudgetLostImpressionShare),
          //Yesterday
       _f(data['YESTERDAY'].Impressions),
       _f(data['YESTERDAY'].Clicks),
       _f(data['YESTERDAY'].AverageCpc),
       _f(data['YESTERDAY'].Clicks) / _f(data['YESTERDAY'].Impressions),
       _f(data['YESTERDAY'].AllConversionValue),
          ];
          return output;
}
 
 
function processAccount() {
 
return JSON.stringify(getAccount(AdWordsApp.currentAccount()));
}
 
 
function allFinished(results) {
  var output = [];
  var sheet = createOrGetSheet(SpreadsheetApp.openByUrl(SPREADSHEET_URL),SHEET_NAME,0);
  
  
  for (var i = 0; i < results.length; i++) { output[i] = JSON.parse(results[i].getReturnValue()); }
   var mccAccountsIterator = MccApp.accounts().withCondition("LabelNames CONTAINS '"+ACCOUNT_LABEL+"'").get();
   if(mccAccountsIterator.totalNumEntities()>50) {
    Logger.log("More than 50 accounts - using altenative method");
    for(var i=0; mccAccountsIterator.hasNext(); i++) {
      if (i<50) continue;
      var oneAccount = mccAccountsIterator.next();
      MccApp.select(oneAccount);
      output[i] = getAccount(oneAccount);
    }
  }
  
    //clear the old report
  sheet.getRange(3,4,200,28).clearContent();
  Logger.log("Output to spreadsheet");
  output = output.sort(sort1st);
  sheet.getRange(3,4,output.length,output[0].length).setValues(output);
}
 
 
function GetData(){
 
  var dates = ['YESTERDAY', 'LAST_WEEK', 'THIS_MONTH', 'LAST_MONTH', 'LAST_7_DAYS', 'LAST_14_DAYS', 'LAST_30_DAYS'];
  var metrics = "AllConversions, AllConversionValue, Cost, SearchImpressionShare, SearchRankLostImpressionShare, \
   SearchBudgetLostImpressionShare, ContentImpressionShare, ContentRankLostImpressionShare, ContentBudgetLostImpressionShare, \
   Impressions, Clicks, AverageCpc, Ctr";
  
  var data = [];
  
  //PERFORMANCE_REPORT
  for (var i = 0; i < dates.length; i++){
    Logger.log("Getting data: "+AdWordsApp.currentAccount().getName()+" - "+dates[i]);
    data[dates[i]] = AdWordsApp.report("SELECT "+metrics+" FROM ACCOUNT_PERFORMANCE_REPORT DURING "+dates[i]).rows().next();
  }
 
  return data;
  
}
 
 
function createOrGetSheet(reportSpreadsheet, name, position) {
  var sheet = reportSpreadsheet.getSheetByName(name);
  if(sheet == null) {
    return reportSpreadsheet.insertSheet(name,position);
  } else {
    return sheet;
  }
}
 
 
function sort1st(a, b) {
    if (a[0] === b[0]) {
        return 0;
    }
    else {
        return (a[0] < b[0]) ? -1 : 1;
    }
}
 
 
function _f(data){
  //remove thousands separators
  return data.replace(/,/g, "") * 1;
 
}
 
function _fp(data){
  //remove percents sign and corrects "< 10%" string
  return data.replace("%","").replace("< 10",10) * 1 / 100;
 
}

Filed Under: Uncategorized

Reader Interactions

Comments

  1. Darryl says

    February 21, 2018 at 10:28 am

    There is apparently a bundle to identify about this. I feel you made some good points in features also.

    Reply
  2. free movie download says

    February 21, 2018 at 8:05 pm

    Hello there, I am truly happy I discovered your website, I basically encountered you by accident, while I was looking on Yahoo for hd movies online. Nonetheless I am here right now and would just love to say thanks a lot for a wonderful article and the all around enjoyable blog (I also enjoy the theme), I do not have enough time to read it completely at the minute however I have book-marked it and moreover added in the RSS feeds, so once I have sufficient time I’ll be returning to browse much more. Make sure you do continue the great job.

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *


Primary Sidebar

Google Partner

Tools

AWQL Generator
Keyword Combinator
Datastudio Case generator

Recent Posts

  • Adwords script for better A/B testing of Ads February 15, 2017
  • OpenRefine: a fast and easy way to obtain keyword data from autocomplete February 15, 2017
  • MCC script for controlling account performance and trends February 15, 2017

Recent Comments

  • how to make a blog on OpenRefine: a fast and easy way to obtain keyword data from autocomplete
  • movie download sites on New columns in AWQL reports based on Adwords API v201601
  • latest movie download on Script for PLA campaign history audit

© Copyright 2016 Lynt services s.r.o.