Tuesday, July 30, 2013

Figuring Out When Your Ad, AdGroup, Keyword, or Campaign Was Created

Knowing when an Ad (or entity) was created is impossible using scripts. That information is simply not tracked in AdWords. The next best thing is to find out when your Ad first started receiving impressions and assume that is when it was created (If an Ad is created but no one sees it, does it really exist?).

So in order to help me keep track of when my Ads entities were created, I put together the following script to apply labels to my Ads entities with the date of the first impression. That way, I can find out what ads entities I created and make sure I don't take action on anything that is too young. I can also make changes to all the ads entities built on a given day relatively easily in the AdWords UI by just selecting the right label.


* Track Entity Creation Date
* Version 1.4
* Changelog v1.4
*  - Removed apiVersion from reporting call
* Changelog v1.3
*  - Updated script to handle all entities
* Changelog v1.2
*  - Fixed an issue with comparing dates
* ChangeLog v1.1
*  - Updated logic to work with larger accounts
* Created By: Russ Savage
* http://www.FreeAdWordsScripts.com
//All my labels will start with this. For example: Created:2013-05-01
var LABEL_PREFIX = 'Created:';
var DAYS_IN_REPORT = 30;
var ENTITY = 'ad'; //or adgroup or keyword or campaign
function main() {
  //First we get the impression history of our entity
  var ret_map = getImpressionHistory();
  //Then we apply our labels
//Function to apply labels to the ads in an account
function applyLabels(ret_map) {
  var iter;
  if(ENTITY === 'campaign') { iter = AdWordsApp.campaigns().get(); }
  if(ENTITY === 'adgroup') { iter = AdWordsApp.adGroups().get(); }
  if(ENTITY === 'ad') { iter = AdWordsApp.ads().get(); }
  if(ENTITY === 'keyword') { iter = AdWordsApp.keywords().get(); }
  while(iter.hasNext()) {
    var entity = iter.next();
    var id = entity.getId();
    if(ret_map[id]) {
      var label_name = LABEL_PREFIX+Utilities.formatDate(ret_map[id], AdWordsApp.currentAccount().getTimeZone(), "yyyy-MM-dd");
//This is a helper function to create the label if it does not already exist
function createLabelIfNeeded(name) {
  if(!AdWordsApp.labels().withCondition("Name = '"+name+"'").get().hasNext()) {
//A helper function to find the date days ago
function getDateDaysAgo(days) {
  var the_past = new Date();
  the_past.setDate(the_past.getDate() - days);
  return Utilities.formatDate(the_past,AdWordsApp.currentAccount().getTimeZone(),"yyyyMMdd");
//A helper function to compare dates.
//Copied from: http://goo.gl/uW48a
function diffDays(firstDate,secondDate) {
  var oneDay = 24*60*60*1000; // hours*minutes*seconds*milliseconds
  return Math.round(Math.abs((firstDate.getTime() - secondDate.getTime())/(oneDay))); 
function getImpressionHistory() {
  var API_VERSION = { includeZeroImpressions : false };
  var first_date = new Date('10/23/2000');
  var max_days_ago = diffDays(first_date,new Date());
  var cols = ['Date','Id','Impressions'];
  var report = { 
  var ret_map = {};
  var prev_days_ago = 0;
  for(var i = DAYS_IN_REPORT; i < max_days_ago; i+=DAYS_IN_REPORT) {
    var start_date = getDateDaysAgo(i);
    var end_date = getDateDaysAgo(prev_days_ago);
    var date_range = start_date+','+end_date;
    Logger.log('Getting data for ' + date_range);
    var query = ['select',cols.join(','),'from',report,'during',date_range].join(' ');
    var report_iter = AdWordsApp.report(query, API_VERSION).rows();
    if(!report_iter.hasNext()) { Logger.log('No more impressions found. Breaking.'); break; } // no more entries
    while(report_iter.hasNext()) { 
      var row = report_iter.next();
      if(ret_map[row['Id']]) {
        var [year,month,day] = (row['Date']).split('-');
        var from_row = new Date(year, parseFloat(month)-1, day);
        var from_map = ret_map[row['Id']];
        if(from_row < from_map) {
          ret_map[row['Id']] = from_row;
      } else {
        var [year,month,day] = (row['Date']).split('-');
        ret_map[row['Id']] = new Date(year, parseFloat(month)-1, day);
    prev_days_ago = i;
  return ret_map;


  1. It’s amazing in support of me to truly have a web site that is valuable meant for my knowledge.

  2. Niche revises position very seriously 90Per cent in our enterprise and why we certainly have in no way essentially exposed our system for the community.https://bizzebee.com/4-simple-seo-tips-for-new-bloggers/ Establish Links of our website - the audience will probably be open up for your personal temporary, until lastly finally we fulfill track of up by including more quite a bit ranges customers accessible

  3. who made the product even offered to set everything up for me for $10 bucks (ideal for me!), so I was following in like 5 minutes. Backlinks service

  4. In keyword research I use the broad match because it will yield the largest number of keyword ideas from which to harvest final keyword gems.google keyword wrapper

  5. Seo firm inside had been large together with his time, while we put in hrs going through the requirements my business in addition to what choosing a company steps browse around here. He's very professional in addition to reputable. Advocate finest search engine marketing into the nearby organization that is looking for.

  6. I have installed the script. It is running, enabled, green icon lighting. But I don´t see the label anywhere. I looked for a colummn Labels, but didn´t find. Please help me. It is my first script I have ever used.

  7. who made the product even offered to set everything up for me for $10 bucks (ideal for me!), so I was following in like 5 minutes.
    field technician job description

  8. Each of the handsets connected with the base unit also has its own speakerphone, so just at the touch of a button, you can enjoy hands-free conversation while you are cooking or doing something else.

    Cordless Phones For Senior

  9. The product has delighted both end users and internal stakeholders. Due to their effective project management and the experience of user experience design agency team they has been able to deliver a high-quality app within a reasonable timeframe. Their professionalism and transparency set them apart.

  10. I appreciate the time you’ve taken out to show me the ropes and ensure that I have the required knowledge to do a great job. Thank you.
    read more

  11. We are a certified troubleshooting guide, available round the clock to provide the best technical support or specialized technical assistance for canon printer users. We work online with live technical support team to help all frustrated canon printer users. If your canon printer has stopped working or showing canon printer not responding issue, our canon support team is very dedicated to solve this error simply. Our canon printer troubleshooting team has the great skills and extensive experience for solving canon printer not printing problem within a few seconds. Our live technical support team is ready to provide quick help for any issues.

  12. We are the simplest , successful, and self-governing third party QuickBooks support provider, which is providing unlimited QuickBooks support services for all frustrated QuickBooks in very nominal charges. once you plan to open a corporation file not located on another computing system , you'll undergo QuickBooks Error H505. This error code is an annoying error, which can't be resolved easily. This error code appears when QuickBooks company file needs some extra configuration. If you're experiencing this error code again and again, you'll call our QuickBooks professionals to urge the specialized assistance for solving this error code simply. So now, you'll enjoy the simplest services with QuickBooks excellently.

  13. Perfect piece of work you have done, this website is really cool with wonderful information.
    Feel free to visit my web blog: Movie reviews - Movie Laundry provides info on movies, movie reviews, ratings, cast and crew details of movies. Get updated movie reviews from movie Laundry.checkout their works at- movielaundry

  14. It has been just unfathomably liberal with you to give straightforwardly what precisely numerous people would've promoted for an eBook to wind up making some money for their end, basically given that you could have attempted it in the occasion you needed.
    CRM with Invoicing

  15. Thankfulness to my dad who informed me relating to this blog, this website is really amazing.

  16. Get ready to boost your business with a strong online presence. Hire India’s most trusted online website development company and get instant quotes. 100% Customer Satisfaction. 1000+ Dynamic Website Designs with built-in SEO. Mobile friendly. Top-notch technology. 24*7 Technical support and much more. Reach us now!

  17. Thanks for compiling such nicest information in your blogs. Articles are very informative and hope again I’ll find more like that.
    web design companies

  18. Great job for publishing such a beneficial web site. Your web log isn’t only useful but it is additionally really creative too. 100 high quality backlinks for $2

  19. Hi to all, the blog has really the dreadful information I really enjoyed a lot.
    UI design company

  20. Sometimes you don’t have time to complete your assignment before deadlines. And due to late submission you can’t get full marks, if you are looking help for completing your assignment then you can contact us. We are providing Online assignment help and we have a team of professional’s academic writers who are more eligible to complete your assignments on time and accurate. For more information visit our website or call us on or Toll free numbers.

  21. The creative minds of Brandphic provide innovative solutions for your business identity and recognition among the audiences. We ensure to make your journey ecstatic by demonstrating our work of art with enthusiasm and determination. branding package

  22. Generally I don't learn post on blogs, but I would like to say that this write-up very pressured me to try and do it!
    Your writing style has been surprised me. Thanks, very great post.
    Cash for Cars Melbourne
    We Buy Cars

  23. The tutorial is very helpful for a first timer like me, by the way if you could have given a tutorial on creating a free website, it would have been very helpful for newbies like me.
    Thank you
    Cash for Unwanted Cars
    Places that Buy Old Cars

  24. Have you ever try online services of Assignment Help even in Malaysia? Are you thinking about the reliability of online services in academic writing? If you have the same questions in your mind, you have to place an order for online services of assignment writing.
    Assignment Helper
    Assignment Help Online

  25. Hello There. I found your blog using msn. This is a really well written article. I will make sure to bookmark it and come back to read more of your useful information. Thanks for the post. I will definitely return.
    Cash for cars Sydney
    cash for scrap cars

  26. Hello There. I found your blog using msn. This is a really well written article. I will make sure to bookmark it and come back to read more of your useful information. Thanks for the post. I will definitely return.
    Car Removal Brisbane
    Cash for Cars Beenleigh

  27. Hey there! I know this is kind of off topic but I was wondering if you knew where I could get a captcha plugin for my comment form? I'm using the same blog platform as yours and I'm having trouble finding one? Thanks a lot!
    Cash for Cars Brisbane
    Cash for Cars Gold Coast

  28. Thanks, foг ones marvelous posting! I genuinely enjoyed reading it, you miggһt Ƅe a great author. I wiⅼl made certain to booҝmark your blog and ѡill often come back sometime soon. I want to encoᥙrage yourself to continue your great job, have a nice evening!
    Cars for Cash Ipswich
    Cars for Cash Brisbane

  29. Wow, that was strange. I just wrote a really long comment but after I clicked submit my comment didn't show up. Grrrr... well, I'm not writing all that over again. Anyways, just wanted to say fantastic blog!
    cash for cars gold coast
    car removal gold coast

  30. Great post. I used to be checking constantly this weblog and I am inspired! Extremely useful information specially the ultimate part :) I maintain such info much. I used to be seeking this particular information for a very lengthy time.
    cash for cars adelaide
    car removal adelaide

  31. Hi This is Noah Dabbler, It is really eye opening post, thanks for sharing it with us, To know more like this type of informative content please visit :FourCreeds

  32. Unique Submission is the most trusted online university assignment help service available today.
    We help students efficiently in completing their due assignments.
    The most distinct feature we offer as a leading assignment help website is confidentiality as customer’s privacy and
    security is of utmost importance to us.

    Assignment Helpers Online

  33. Thanks for posting such an awesome post. to know more visit FourCreeds

  34. Thank you for this use Full Post!

    as it contains a lot of information. I always prefer to read the quality content and this thing I found in you post. Thanks for sharing. https://godsofseo.com/

    Guest Posting Sites
    Guest Posting Site
    Guest Posting Websites
    Forum Submission Sites
    Forum Submission
    Forum Posting Sites
    Forum Submission List
    Forum Posting
    Video Submission Sites
    High PR Video Submission Sites
    Video Sharing Website
    Web 2.0 Sites
    Web 2.0 Sites List
    Best Web 2.0 Sites for Backlinks
    Web 2.0 Submission
    Question and Answer Websites
    Question and Answer Sites List
    Question and Answer Sites
    Question and Answer Sites for SEO

  35. Very Nice Post ...I always prefer to read the quality content and this thing I found in you post. Thanks for sharing. https://www.victoriasecretgiftcardbalance.com/

    Victoria Secret Check Balance
    Victoria Secret Gift Card Balance
    Check Victoria's Secret Gift Card Balance
    Victoria Secret Card Balance
    Check Victoria's Secret Gift Card Balance
    Check Victoria's Secret Card Balance

  36. I am gonna share your post on social media.
    Data warehouse India

  37. I haven’t any word to appreciate this post.....Really i am impressed from this post....the person who create this post it was a great human..thanks for shared this with us. backlinks

  38. All these tips and tricks are helpful for those who have some kind of skills in writing and meet some kind of assistance but it is pointless for those who couldn't write a single paragraph on their own taking cheap paper writing service is the last and best choice for those students because they well-written paper according to the requirements. that's why i only trust helpinhomework.org. Their service and study material are very reliable, you must also try. help in homework

  39. This blog is so nice to me. I will keep on coming here again and again. Visit my link as well.. family relationship

  40. Good blog.Are you also searching for Help With My Nursing Paper? we are the best solution for you. We are best known for delivering nursing writing services to students without having to break the bank.

  41. Good blog. Keep sharing. I love them Are you also searching for Cheap assignment writers? we are the best solution for you. We are best known for delivering nursing writing services to students without having to break the bank

  42. This is quite a good blog.Are you also searching for Nursing Research Paper Help? we are the best solution for you. We are best known for delivering nursing writing services to students without having to break the bank.

  43. Appreciating the time and effort you put into your website and the thorough information you present. It’s amazing to come across a site every now and then that is not the similar old re-written material. Excellent read! We’ve bookmarked your site. Regards cash for cars gold coast

  44. Professional and friendly service anywhere in Brisbane cash for car including North, West, East, and Southside. Make a deal and sell your vehicle in seconds with or without rego or roadworthy.

  45. Are you also searching for nursing writing services we are the best solution for you. We are best known for delivering the best services to students. 

  46. EndNote Crack Anyone can add instructions and uses at the same time. You do not have to work with their own people. the software gives you permanent access to a variety of locations. and shows the same solution altogether. But change classes to follow books that someone else has made this change. and Save your money for your research. Shares, books, books that do not store security books, year-olds are not stored for a year.

  47. The team worked smoothly top web designer hroughout the development process instrument design portland, understanding both the design and technical requirements fully.

  48. Printer issues can seem daunting when you are trying to print. However, most of these issues are common and can be fixed instantly. With the proper knowledge of the issue, users can easily get the issue fixed. Here is how you can fix the Epson windows service disabled error on your own.

  49. We pay our customers up to $9,998 for their old, scrap, or unwanted cars, and offer a free quote and complimentary removal services. Selling a car is easy with us, we have a wide network of clients all over QLD which can help us in selling your car within 24 hours.

    broken car collection brisbane

  50. I really impressed after read this because of some quality work and informative thoughts . I just wanna say thanks for the writer and wish you all the best for coming!. receive SMS free

  51. More details on: https://www.techsplace.com/

  52. We are buying old cars for cash and picking it up for free. Call Us and get top cash for used and old cars and also get a free quote. We will give you the best assistance and 24/7 support for selling your car. Make it a quick deal and get rid of your used car within the same day.
    cash for car adelaide

  53. This comment has been removed by the author.

  54. We Buy Vehicles provide customers a great opportunity to get rid of their old unwanted car fast. We help customers all over Victoria by selling their cars and giving cash in return. Our services include car wrecking, car removal, cash for cars, and eco-friendly recycling.

    car removal logan

  55. North Brisbane Wreckers have been improving people's lives since 2014. We are the top cash for car company in the North Brisbane area. We aim to provide customers top quality service and convenience when selling their car.

    north brisbane wreckers

  56. A1 Wreckers is reliable cash for car business in the Brisbane area. We believe that customers' time should be spent doing things they want, not spending time thinking of ways to get top cash for their car on the market.

    cash for scrap cars Logan

  57. the car rental industry since the effects the substitute products have do not pose a significant threat of profit erosion throughout the industry. İstanbul araç kiralama

  58. The team conducted a site niche edit services before they performed changes. At the same time, they also implemented link building.

  59. Well to be very honest, I was not expecting such a great blog. I totally loved it, you have written it with so beautifully and softly.

    salisbury wreckers

  60. Fast Cars Removal was created to fill the need for efficient car buying companies. Most car buyers ten years ago were junkyards. These junk yards did take your old vehicle but never paid much. To fill this gap Fast Cars Removal came into existence.

    cash for car south brisbane

  61. Our company was started because we wanted to improve the ongoing cash for car process. We knew if we wanted to reach the top we needed to provide services which were better than our competitors and also different from them. That’s when the idea of WeBuyVehicles came into existence.

    car wreckers brisbane

  62. A1 Wreckers is reliable cash for car business in the Brisbane area. We believe that customers' time should be spent doing things they want, not spending time thinking of ways to get top cash for their car on the market.

    car removal ipswich

  63. Students have to learn a lot, especially in mechanical engineering because of the vast syllabus and topics that are needed to complete. Subjects like thermodynamics, fluid mechanics, the strength of materials, etc. are very difficult to learn and are one of the most important subjects in mechanical engineering. To ensure that students get good marks in their assignments and have ample time to learn about the various topics we at Assignment Help provide online assignment help to all students under the Mechanical Engineering Assignment Help.

  64. A1 Wreckers is reliable cash for car business in the Brisbane area. We believe that customers' time should be spent doing things they want, not spending time thinking of ways to get top cash for their car on the market.

    sell my car toowoomba

  65. Canberra Cash 4 Cars was started to fulfill the gap in the market for cash for scrap car services. End-of-life vehicles were piling up in the area with only a few places for them to be sold.

    Cash for Cars Canberra

  66. For Eco-Friendly Recycling Services of your old Car and quick Cash for Unwanted Cars Brisbane Services, we Ezy Cash for Cars is the Best. If you have an old car in your garage and you want to get that space cleaned, just contact and we offer our services in time. In addition to cash for your damaged car, we provide free removal services also. Reach us at https://ezycashforcars.com.au/

  67. You should initially perceive what to check in choosing the correct party to have your perfectly developed research projects. Course appraisal errands and research papers are a wide zone of various affiliations professing to be cultivated authors without a lot to show for! So when you simply go to Google and type 'compose my paper for me' and utilize the one name first that surfaces, you'd be quite mistaken! visit - do my assignment , assignment provider

  68. Great article! The information you have shared is very engaging and impressive. It’s hard to come by experienced people talking about this subject! Thank you. Visit our reliable Dissertation Finishing Service for assistance with completing your research project.

  69. You can reinstall or install Microsoft Office Setup at office.com/setup

  70. Thanks for sharing this nice post.
    Don't know how to configure Roadrunner Email Setup? We can help you in configuring this setup. You have to follow some steps and you can easily perform the Roadrunner email setup.

  71. You can never turn out badly with gifting a bouquet; it matches with each event. Wishing to Send Flowers to Noida? What's preventing you from picking flower blessings as the most ideal alternative? A botanical blessing satisfies one it lights up their state of mind, paying little heed to any sexual orientation.

    Online Flowers Delivery In noida