Please note: this is not an officially supported Google product.
This repository holds a proof of concept to automate the process of taking on-site screenshots of ad creatives for Ad Manager publishers.
- ghys@google.com (LouGhys on Github)
We're always looking to improve this, contributions are always welcome! Simularly, if you used this, let us know and give us feedback!
See contributing.md
for ways to get started.
Before running the application, the following steps and tools are needed on the device where both server will be ran:
- Node
node --version
: 16.19.0
- yarn
npm install -g yarn
yarn --version
: 1.22.19
- Python 3
python --version
: 3.11.4
- pip
pip --version
: 24.0
- Google Chrome
- the selenium headless browser runs on chrome
- A Google Cloud OAuth2 client (see below)
- Configured
/server/src/.env
(see below)
This project uses Google OAuth 2.0 and sends credentials to the Google Ad Manager API, using the web client auth flow.
Therefore, a Google Cloud project and an OAuth 2.0 web client is required.
After creating a Google OAuth 2.0 Web Client in the Google Cloud console, fill in the environment variables correctly, as described in the .env.example
file.
- Copy the
.env.example
file and rename it to.env
- Fill in each of the constants in that
.env
file accordingly - On requests, the server will use the secrets stored in the server's cached
.env
file
The /server/
folder is the backend for the client side application of this project.
Deploying and using this backend can be done seperatly from the frontend. Out of the box, the backend handles autentification, Ad Manager data fetching, creating and serving the creative on-page screenshots.
Note that the backend can be used standalone without the frontend.
- Make sure to follow the prerequisites
- Install dependencies
pip install -r requirements.txt
- Run the server with python
python server.py
- The servers endpoint: http://localhost:8080.
- Check 200 status is returned /ping/ and returns
200
and"pong"
- API's documentation: /docs/
This react application is the client side application of this project.
- Make sure to follow the prerequisites
- Install dependencies
yarn
- Generate API client (make sure your backend server is running at http://localhost:8080)
- This will create the API client typescript files under
/generated/
- This will create the API client typescript files under
yarn generate-api-client
- Run the frontend server in dev mode
yarn start
- The server should be live at http://localhost:5000.
- For the Google login, please use the account tied to your Google Ad Manager network
From step 1 & 2 of the setup, you should now have 2 servers running:
- The frontend on port 5000 (ex http://localhost:5000)
- The backend on port 8080 (ex http://localhost:8080)
Our recommendation is to create a Docker image containing both servers and all their dependencies (Selenium, node, etc…). Once you have a Docker image, a can use it in Google Cloud Run, as lightweight infrastructure.
- FastAPI
- Python web-api framework. Choosen for it's depency injections and popularity
- GoogleOAuth
- Most of the auth code is run on the server-side, needed for authentification for Google product like the Ad Manager API
- Google Ad Manager API
- Used for fetching data from your ad manager account
- Selenium
- A chrome web driver is used for opening a creative preview's website and take screenshots
- React
- Chakra UI
- ES Build (For bundling and packaging)
- Auto-generated API client from OpenAPI spec