Wednesday, August 16, 2017

Automatically add AdWords Data to a Google Slide

Have you ever had to give a presentation about the performance of an AdWords account and spent a lot of time copy-and-pasting data from AdWords into your slides? If so, now you can automatically push data from AdWords into Google Slides.



This script leverages the recently announced integration of AdWords Scripts with the Google Slides API. Because this is one of the advanced APIs, the code is a bit more complicated and you will have to enable the Google Slides API from the script through an additional authorization step.

The code below appends a new slide to your Google Slide deck and adds some basic AdWords metrics. You can modify this code to add exactly the data from AdWords you want.


/* 
// AdWords Script: Add a Slide with AdWords Data
// --------------------------------------------------------------
// Copyright 2017 Optmyzr Inc., All Rights Reserved
// 
// This script takes a Google Presentation as input and appends a slide with basic AdWords metrics.
// Use this to automate creating an appendix of AdWords data to existing PPC report slides.
// The AW data we append is basic but can easily be tweaked to your own needs.
//
// For more PPC management tools and reports, visit www.optmyzr.com
//
*/

// Update this line with the presentation you want to edit. 
// E.g. this is for presentation https://docs.google.com/presentation/d/1RxIzTJC6Jwwd3H5aaRjA-zj3d5IhcG9uOTuOfwk8PUg/edit#slide=id.optmyzr_slide_a1f911e6-9538-427d-9e2f-12fdc951f752
var PRESENTATION_ID = "1RxIzTJC6Jwwd3H5aaRjA-zj3d5IhcG9uOTuOfwk8PUg"

function main() {
  
  var pageId = createSlide(PRESENTATION_ID);
  
  // Get the page element IDs for a basic TITLE_AND_BODY layout
  var baseElementId = readPageElementIds(PRESENTATION_ID, pageId);
  var titleId = baseElementId + "_0";
  var textId = baseElementId + "_1";
  
  // Edit the following with the text for the slide's title
  var titleText = "Automatically Fetched AdWords Data";
  updateElement(PRESENTATION_ID, titleId, titleText);
  
  // The next line gets text for the body section
  var dataForSlide = getLastMonthData();
  updateElement(PRESENTATION_ID, textId, dataForSlide);
  
  Logger.log("Done updating slides at https://docs.google.com/presentation/d/" + PRESENTATION_ID);
  
}

function getLastMonthData() {
  var currentAccount = AdWordsApp.currentAccount();
  //Logger.log('Customer ID: ' + currentAccount.getCustomerId() +
  //    ', Currency Code: ' + currentAccount.getCurrencyCode() +
  //    ', Timezone: ' + currentAccount.getTimeZone());
  var stats = currentAccount.getStatsFor('LAST_MONTH');
  var clicks = stats.getClicks();
  var impressions = stats.getImpressions();
  var text = clicks + " clicks from " + impressions + " impressions.";
  return(text);
}

function createSlide(presentationId) {
  // You can specify the ID to use for the slide, as long as it's unique.
  var pageId = Utilities.getUuid();

  var requests = [{
    "createSlide": {
      "objectId": pageId,
      //"insertionIndex": 1,
      "slideLayoutReference": {
        "predefinedLayout": "TITLE_AND_BODY"
      }
    }
  }];
  var slide =
      Slides.Presentations.batchUpdate({'requests': requests}, presentationId);
  //Logger.log(slide);
  //Logger.log("Created Slide with ID: " + slide.replies[0].createSlide.objectId);
  
  return (pageId);
}

function updateElement(presentationId, elementId, textToAdd) {
  
  var requests = [{
      "insertText": {
        "objectId": elementId,
        "text": textToAdd,
      }
    }];
  var result =
      Slides.Presentations.batchUpdate({'requests': requests}, presentationId);
  //Logger.log(result);
}

function readPageElementIds(presentationId, pageId) {
  // You can use a field mask to limit the data the API retrieves
  // in a get request, or what fields are updated in an batchUpdate.
  var response = Slides.Presentations.Pages.get(
      presentationId, pageId, {"fields": "pageElements.objectId"});
  //Logger.log(response);
 var objectIds = response.pageElements[0].objectId;
  var parts = objectIds.split("_");
  var objectIdBase = parts[0] + "_" + parts[1];
  //Logger.log("objectIdBase: " + objectIdBase);
  return(objectIdBase);
}

We maintain the most current version of this code on GitHub.

For a fully automated way to create PPC reports with interesting visualizations like Quality Score, a word cloud, a cause chart, or a heatmap, take a look at Optmyzr, my company.

Thanks,
Fred

28 comments:

  1. very interesting, good job and thanks for sharing such a good Post | blog.
    Best website designing company in Laxmi Nagar

    ReplyDelete
  2. Thank you for taking the time to publish this information very useful! High Quality Google Reviews

    ReplyDelete
  3. Yes. This code is absolutely correct and working. I'd like to thank you man for sharing this free. buy google reviews

    ReplyDelete
  4. Do you want your university to become number one? Vote for it here https://writemyessay4me.org/blog/university-rankings

    ReplyDelete
  5. Google reviews has proven to become a good element in anyone's business. Besides, it has become a essential aspect in effective business as well. Investigate Buy Google Reviews this page for fruitful information now.

    ReplyDelete
  6. SEO arama motorlarının bellirlediği kriterlere göre web sitenizin optimize edilmesi ile hedeflenen anahtar kelimelerde üst sıralarda yer almasını hedeflemektedir.

    ReplyDelete
  7. Boost your social media presence instantly get famous.Know how to get real instagram followers cheap.
    internetmarketingrocks

    ReplyDelete
  8. This is really a nice and informative, containing all information and also has a great impact on the new technology. Thanks for sharing it buy real australian instagram likes

    ReplyDelete
  9. Links are one among the crucial ranking factors, probably the leading free seo tipps component, and we’ll dedicate several lessons to link building during this SEO course.

    ReplyDelete
  10. Very informative post! There is a lot of information here that can help any business get started with a successful social networking campaign. survey data entry

    ReplyDelete
  11. the information you provide on this website has helped me tremendously. Thanks for all
    of your time & work. Paraphrase Service Uk

    ReplyDelete
  12. hp fax error 344 happens when there is any correspondence blunder in the telephone line. ... Last Word from Experts for Error Code 344 HP Fax.

    ReplyDelete
  13. The ad word script is very helpful for many user who want to get the script all over the a huge people also want to earn online through the google ad word and it's the best idea many web development service company in Pakistan also build the blog sites for ad words and also earn a big amount online

    ReplyDelete
  14. wow, cool article, thanks
    also, if you need a social media accounts you can visit accsmarket store

    ReplyDelete
  15. This comment has been removed by the author.

    ReplyDelete
  16. If you need to buy everything with discount, for example, food and different drinks, you can visit the rabato.com which has fresh Weekly Ads on different stores.

    ReplyDelete
  17. Google Reviews send customers a positive or negative response to your business, online-store, Restaurant or requirements. You can Expect your SEO rank of google reviews. Scroll down you can see the advantage of buying google reviews We will discuss many kinds of topic about buying Google reviews.

    We know all reviews platform always promote your business and also virtual shopping assistant. So, We provide fresh/real/good Ip’s Reviews with multiple devices. Our reviews will be not removed on your business page, maps, places. We can do USA, UK, CA and AU profile must be. also if you need any custom country we can do that. actually our service worldwide

    buy google reviews

    ReplyDelete
  18. WiFi Hacking Free Download may be a “one-click” hack tool that helps you to hack any WiFi network password. Following One-Click hack will mean to download and set up this software, and it'll robotically hook up when it finds any wireless signal near you. This hacking tool works enormously successfully. https://freeprosoftz.com/wifi-hacking-password-2021/

    ReplyDelete


  19. We came across it from another site and thought I should check it out.
    I like what I see, so now I'm following you. Presin
    repeatedly look at your site.
    hitfilm pro crack
    macbooster crack
    eventide anthology crack
    free studio crack

    ReplyDelete
  20. Hey there! This is a great post with some informative things. Keep posting this kinds of informative articles.
    Buy Google My Business (GMB) Reviews/Rating on Google Permanent & Lifetime Guarantee with 100% Safety. GEO Targeted Local USA UK CA AU & more Here:Buy google reviews

    ReplyDelete

  21. Hi! This post couldn't have been written any better!
    As I read this post, I am reminded of my old roommate!
    He always talked about it. I will forward this
    send him a message. I'm sure he will read it right. thanks
    For exchange!
    hitfilm pro crack
    macbooster crack
    eventide anthology crack
    free studio crack

    ReplyDelete
  22. I really like the design and layout of your website. This is pleasing to the eye, making it frequent here Do you hire developers to create themes? Great!
    serif affinity designer crack
    du meter
    nitro pro crack
    360 total security premium crack
    vuescan crack

    ReplyDelete
  23. Your blogs are great.Are you also searching for Pico assignment? we are the best solution for you. We are best known for delivering nursing writing services to students without having to break the bank.

    ReplyDelete
  24. I love your creativity. Are you also searching for nursing writing services? we are the best solution for you. We are best known for delivering nursing writing services to students without having to break the bank.

    ReplyDelete
  25. Shopping for Google Opinions could be a highly effective strategy to promote your website or weblog. You would possibly suppose that having the voice of your organization heard on Google is an efficient technique to construct up your model, however sadly, that goodwill is not going to come low cost. On common, the value of a Google search range from $35 - $70, whereas the value varies significantly for various firms. It's due to this fact necessary to grasp simply what you'll be able to count on while you Buy Positive Reviews Online, the best way to use them in your marketing campaign, and the place to purchase them from, to be sure you get one of the best worth for money.

    ReplyDelete