Giter VIP home page Giter VIP logo

trq0 / bing-ads-ad-report-to-google-sheets Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 27 KB

This script fetches data for past 7 days via the Bing Ads API and copies it to a Google Spreadsheet. In the process a temporary csv file that contains the copied data for that day is made in the data folder which is cleaned on every 1st date of the month

Python 100.00%
bingads bingads-api google-sheets-api

bing-ads-ad-report-to-google-sheets's Introduction

Dependencies for the script:

Bing Ads

  • Change the client ID or client token if you ever choose to change the associated Bing Ads account
  • Follow the guide:
    • to setup a client guide
    • to get a developer token guide
  • These fields are located in main.py having the names CLIENT_ID and DEVELOPER_TOKEN respectively
# Required
CLIENT_ID = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
DEVELOPER_TOKEN='xxxxxxxxxx'

Google Sheets

  • Use this guide to create a Google Cloud project if not already and get the credentials for authentication
  • Copy the credentials json file to the credentials folder (create the folder if not already) and rename the credentials file 'credentials/service-account-credentials-live.json' in
credentials_path = os.path.join(script_dir, "credentials/service-account-credentials-live.json")

located in gs_interface.py

  • After making a service account and generating a service account email make sure to give the email neccessary permissions for the spreadsheet by clicking on Share in the google sheet and sharing it to the service account email
  • In the script gs_interface.py, change the fields SPREADSHEET_ID and RANGE if need be.
  • The SPREADSHEET_ID is found in the spreadshield url. For example in the spreadsheet https://docs.google.com/spreadsheets/d/1234567890-rc12345vjtWAaQthe part after /d/ is the spreadsheet ID which in this case is 1234567890-rc12345vjtWAaQ
  • The RANGE variable contains the sheet name withing the spreadsheet and the cell ranges from where to where the data needs to change. For example here we have RANGE = 'Sheet!A2:N', here Sheet is the name of the sheet ! is the separator and A2:N is the cell range withing the excel sheet

Setting up environment for executing the script

  • Use the command pip install -r requirements.txt to install all the required dependencis
  • On first execution of the script you need to authenticate the application with microsoft. This can be done by copying the authentication link that will be printed in the console upon first authentication and then following the instructions presented in the console
  • If for any reason you cannot access the link in the console then the authentication link is logged inside log/app.log
  • After authentication you need to copy the code query parameter from the link that is presented after successful authentication, the link may look like this https://login.microsoftonline.com/common/oauth2/nativeclient?code=xxxxxxxx
  • The token is then to be copied into the refresh.txt file (make if not exists) inside credentials folder (make if not exists), after then the script should run correctly

Running the script

  • Execute the main.py script by using the command python3 main.py

Default behaviour

  • This script was made with the purpose of updating the bing ads data for the past 7 days to a sheet named tech within a google spreadsheet

Logging

  • The log for every execution can be found inside log/app.log file
  • The log contains all necessary info, warning and error messages

bing-ads-ad-report-to-google-sheets's People

Contributors

trq0 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.