Coder Social home page Coder Social logo

google-ads-api-utilities's Introduction

Setup

  1. Get the details required in the google-ads.yaml file.

  2. Download the OAuth json file from the Google console as secret.json.

  3. Put them in the /config/ directory.

  4. Run the following:

    $  python authenticate_in_standalone_application.py --client_secrets_path=secret.json
    

This will give the URL to authorize. Complete and get the access token and refresh tokens and fill in the refresh token in the YAML file.

Building the client

When running examples, when building the client, just pass the file path as an argument to the load_from_storage() method like this:

google_ads_client = (google.ads.google_ads.client.GoogleAdsClient.load_from_storage('/config/google-ads.yaml'))

Beginner Insights

Things can be broken down into two main use cases. Reporting, and actually managing/editing accounts. So far, the code in this repo is only useful for reporting. Particularly for reporting that isn't available in the web UI (multi dimensional reports).

So for every report, we need to query the ga_service.search or ga_service.search_stream methods, passing it our client and a query. The query is the tricky part as the documentation is not beginner friendly. Particularly the view resource that needs to be queried. The FROM clause specifies the main resource that will be used to select fields. More details can be found here: https://developers.google.com/google-ads/api/docs/query/structure#from

Time based reporting

In your GAQL queries, if you want to segment by date (for example, a daily report), you need to include the segment.date segment resource in your select statement, not just the where statement.

Notes

The list_accessible_customers file will only get a list of MCCs you have access to as well as accounts that you have been added to as an admin directly. Usually, this isn't what you want. I've built a crude get_account_hierarchy file that loops through the accounts in your MCC and gives you back the CIDs. This is most likely what you want.

ToDo

Queries with string based where clauses like:

  "SELECT CampaignName, Clicks, Cost " + //sample metrics
  "FROM CAMPAIGN_PERFORMANCE_REPORT " +
  "WHERE CampaignName CONTAINS '" + names[i] + "'" +
  "DURING THIS_MONTH " //sample date range

Turn this into a package that can be called with easier parameters.

A predefined ENUM list of GAQL queries to get up and running faster in future

Potential Use Cases

  1. Apply recommendations
  2. Check AccountBudgetProposal resource, and compare with ROAS to accept or decline.
  3. Reduce/Increase bids depending on ROAS

Mappings and Views

A list of logical (Old AWQL) reports and their new mappings in the Google Ads API is here: https://developers.google.com/google-ads/api/docs/migration/reports

google-ads-api-utilities's People

Contributors

davedavis avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.