Google Ads Automation with Python – How to Connect to API Tutorial (#1)

    10
    38



    Here is step-by-step instruction on how to start working with Google Ads with Python and API.
    Try to watch in 1.5x speed if it’s a bit too long šŸ™‚

    00:00 Intro & Talks
    01:24 Yaml Credentials
    02:57 Python & PyCharm
    03:59 Google Ads Library
    04:57 Getting Developer Token
    11:14 Getting Client ID & Secret Id
    13:00 Getting refresh token
    15:40 Running your first script

    Useful Links:
    1. Download Python https://www.python.org/downloads/
    2. Download PyCharm https://www.jetbrains.com/pycharm/download/#section=windows
    3. Official Library https://github.com/googleads/googleads-python-lib/tree/ca06aaae68c1cfea8bc80be1f019980c2caec5dc
    4. My Source Code https://github.com/RPetrochenkov/google_ads_tutorials
    5. Refresh token how-to https://github.com/googleads/googleads-python-lib/wiki/API-access-using-own-credentials-(installed-application-flow)
    6. GAQL Builder: https://developers.google.com/google-ads/api/docs/query/interactive-gaql-builder

    This tutorial playlist: https://www.youtube.com/watch?v=cKODT6-u_bA&list=PLGXZC1nQpK7drhMnvSV2RHl7FTCEEGD3S

    Google Ads into BigQuery Playlist: https://www.youtube.com/watch?v=Hi80puAbDH0&list=PLGXZC1nQpK7cu_kDkrne-vSxzpMTiAlEW

    Read me on Medium: https://medium.com/@rpetrochenkov
    Add me on LinkedIn: https://www.linkedin.com/in/rpetrochenkov/

    šŸ“Œ Want to discuss your project?
    – Me on UpWork: http://bit.ly/3hKa3qC-MWH
    – Me on Fiverr: http://bit.ly/3oiAeac-MWH

    My other Google Ads Scripts tutorials: https://www.youtube.com/watch?v=c2JjxqgsbJ4&list=PLGXZC1nQpK7dvkAdl9PR04UobAGFa_j8e

    source

    Previous articleBusiness Analyst jobs in Canada | Colleges, Certifications, Skills, Salary. Real review
    Next articleAWS Boto3 Python Crash Course with AWS EC2 Instance

    38 COMMENTS

    1. Hey ! Thank you so much for the video, it still helps 2 years later !
      But on the generate_refresh_token.py execution, the Google page show up with a 400:invalid_request error
      it seems to be caused by the redirect URI (urn:ietf:wg:oauth:2.0:oob).
      But the developer says that the redirect uri for an installed application will always have this value.
      I don't know what to do T.T

    2. Thanks for the informative video !
      But while generating refresh token facing the following issue : "Error 400: invalid_request. You can't sign in to this app because it doesn't comply with Google's OAuth 2.0 policy for keeping apps secure."
      Any inputs or comments on this issue would be really helpful.

    3. Hello there šŸ™‚ First of all thanks for the vid! It's really helpful.
      I had one problem, Error 403 "The developer hasn’t given you access to this app. It’s currently being tested and it hasn’t been verified by Google. If you think you should have access, contact the developer" but I am the developer and it's my account… What should I do? then there was a message "If you’re the app developer, make sure that these request details comply with Google policies." But I couldn't find where to check "Google policies". Can you help out, please?

      P.S. "just spending half an hour on this video and then spending a few weeks on making it all work, this script actually runs which is an amazing success" << This was really uplifting for beginners šŸ˜€ to give us adequate estimation of time-frame šŸ˜€

    4. Hello man. First I would like to thank you so much for this detailed tutorial, it seems to be really usefull.

      I'm currently working on getting some reports from Google Ads API to a Google Colab notebook, as I previously did this with Google Analytics API. Some of the credencials and authorization issues seems to be similar, and I recognize this is the most annoying and difficult part, so your comments and this video are really helpfull!

      Only one thing I would like to alert. The "from google.ads.google_ads.client import GoogleAdsClient" library part 4:58, where you import this library seems to be wrong. The correct library to import is from "google.ads.googleads.client import GoogleAdsClient". See, its NOT google_ads, but the correct syntax is googleads, after second dot.

      I'm not expert in programming, but at least for google colab notebook this is the way it worked for me. I still didn't get any reports because I'm still writing the script, but if I get any trouble or more comments I will leave it here.

      See ya!

    5. I agree. I’ve been busy with this for about a month now. Very frustrating.
      I have a few questions. Like you I also have about 20 web pages open trying to find info on the same thing.
      I need my script to run without any user interaction. So I was looking at the service account. But I am confused as it seems that I could use the app OAuth. If I use the app OAuth. Do you need to approve the connection every time the script runs, or do you only need to do this once, and then just use the refresh token that is generated?
      Then do I need an approved token for it to work, or can I used the token with the test account as indicated by the documentation? Currently when I use the service account and try to impersonate another user. It returns NOT_ADS_USER. Not sure if this is because I’m using the token in test status.

      Thanks for the video. You got my subšŸ˜€

    6. thank you for this walkthrough. my refresh token expired after 7 days – and I don't want to publish my app. Is there any way you know of to keep the refresh token active forever? Also don't want to pay for a google workspace account which would allow me to keep the oauth consent screen internal…

    7. Hey man I hope you realize this is the most thorough information regarding Google ads API access. I’ve filled out my entire yaml file before finding this and had no idea what it was used for.

      I’m not done yet but this video definitely will help me along the way.

    8. It might be obvious but just want to confirm, in main(gads_client, "7036865393") function, 7036865393 is the client account id under your MCC account, 262-999-8397? I asked so because when I ran the main function with 2 following arguments, including my google-ads.yaml file and MCC account, it returned the error "Metrics cannot be requested for a manager account. To retrieve metrics, issue separate requests against each client account under the manager account."

    9. I want create a project with django. In this site the user can create campaign in google ads more fast(this is the business). Do u know if the user(client of my business) need a exclusive developer token to login in your own gads account or with my developer credentials I am able to login the different users to manage your own accounts in my project with django?

    10. Do I need to use Google Ads before applying to Google Ads API key? I tried to fill the form with no spend history in Google Ads and got rejected because of this.
      I pretend to use the API to generate keyword ideas for internal use of the company I work, it's a local news website and we pretend to perform better in SEO using keyword ideas, is that possible?

    11. Thank you for uploading, I understand how challenging this API is. I am stuck at creating a testing account with a red "testing account" label. I can authenticate with OAuth2, and list accessible accounts using python example.py. But when I try to get any other information such as campaign details, or anything else, I keep getting the error of permission denied, this can only be used against test account. Although I made a separate account manager which is alos a test, but I am stuck! No help on stackoverflow either.