AdWords
2.3K members online now
For issues or questions regarding logging in, account access, or account security
Guide Me
star_border
Reply

Quality Score Tracking Script

[ Edited ]
Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi I am using the following script to track QS changes on keyword level through labels, although after Google's update on QS ("null") i am getting the following error.

TypeError: Cannot read property "-" from null. (line 48)...any solution update on this script that can solve this error?



var email_address = "notshown@notshown.com"; // Change this to be notified of changes
var label_name = "Track New QS";

function main() {
var labelIterator = AdWordsApp.labels().withCondition("Name = '" + label_name + "'").get();
// If there is no label, this is the first time this script is running
if(!labelIterator.hasNext()){
// Create the spreadsheet
var spreadsheet = SpreadsheetApp.create("AdWords Quality Score Tracker Final");
Logger.log("Spreadsheet for QS history created: " + spreadsheet.getUrl());
var sheet = spreadsheet.getActiveSheet();
sheet.setName("QS history");
// Put in the table headings
sheet.getRange(1, 1, 1, 6).setValues([["Date", "Campaign", "AdGroup", "Keyword", "Quality Score", "Change"]]);
sheet.getRange(1, 1, 1, 6).setFontWeight("bold");
// Create the label and save the spreadsheet's URL in the description
AdWordsApp.createLabel(label_name, "Marks Keywords for QS tracking. Results are here: " + spreadsheet.getUrl() + " (keep URL in this description)", "#339999");
Logger.log("Label '" + label_name + "' has been created. Apply this label to all keywords want to track. Then run the script again.");
for(i = 1; i <= 10; i++){
AdWordsApp.createLabel("QS: " + i, "Used for QS comparison.", "#ffffff");
}
Logger.log("Ten additional labels ('QS: 1' to 'QS: 10') have been created. Those are needed by the script to compare old and new Quality Scores later. You can just ignore those.");
return;
}

// There is a label so get it and get the spreadsheet's URL from its description
label = labelIterator.next();
var matches = new RegExp(' (http(s?)://[^ ]+) ').exec(label.getDescription());
if (!matches || !matches[1]) {
throw "Couldn't get spreadsheet URL from label description: " + label.getDescription();
}
var spreadsheetUrl = matches[1];
var spreadsheet = SpreadsheetApp.openByUrl(spreadsheetUrl);
var alert_text = new Array();
var history = new Array();
var currentTime = new Date();
var today = (currentTime.getMonth() + 1) + "/" + currentTime.getDate() + "/" + currentTime.getFullYear();
var keywordIterator = label.keywords().get();
var line_counter = 0;
while (keywordIterator.hasNext()) {
var keyword = keywordIterator.next();
line_counter++;
var current_quality_score = keyword.getQualityScore();
keywordLabelsIterator = keyword.labels().withCondition("Name STARTS_WITH 'QS: '").get();
if(keywordLabelsIterator.hasNext()){
keyword_label = keywordLabelsIterator.next();
var matches = new RegExp('QS: ("[" "-9]")$').exec(keyword_label.getName());

1 Expert replyverified_user

Re: Quality Score Tracking Script

Top Contributor
# 2
Top Contributor

Hi @Eleftherios D where did you source the original script?  Your best option is to look at the originating site, or contact the originating author.

 

Jon

AdWords Top Contributor Google+ Profile | Partner Profile | AdWords Audits