Skip to main content

Manages tasks in Google Ads

Project description

bach for Google Ads

bach provides an easy to use set of abstractions to simplify developing Google Ads solutions related to Google Ads management. Most of the solutions consist of three phases:

  • Extract some data
  • Do some transformation
  • Do something with transformed data

bach solves first two generically by simplifying fetching data and applying filtering rules to the fetched data; the third step is defined as an interface developers can use to build on top of it.

Responsible for orchestrating rules and applying complex rules in Google Ads. Consists of 3 elements:

  • Rule to Query - takes complex rules and build GAQL query out of it; query is executed and returned as a Report.
  • Rule to Report - applies Rule to Report to get a subset of actionable entities.
  • Report to Action - does whatever needs to be done with the subset of data (notification, exclusion, increase / decrease).

Installation

pip install bach-googleads

Usage

  1. Simple use case - use predefined queries.
from bach import (
  Bach,
  actions,
  notifications_channel,
  plugins,
)
from bach.adapters import repositories

task_repo = repositories.SqlAlchemyRepository(
  db_url='sqlite:///tasks.db', model=tasks.Task
)

bach = Bach(task_repo)

(
  bach
  .with_type('placement_performance')
  .with_accounts(ACCOUNT_ID)
  .with_actor(
    plugins.PlacementExclusionActor,
    exclusion_level='CAMPAIGN',
  )
  .add_rules('clicks > 10')
  .add_action(actions.Action.EXCLUDE)
  .add_notify(notifications_channel.Console())
)

bach.run()
bach_task = bach.as_task(name='task_name')
  1. Simple use case - use custom query.
from bach import Bach

query = 'SELECT campaign.id, metrics.clicks AS clicks FROM campaign'

(
  bach
  .with_accounts(ACCOUNT_ID)
  .add_rules('clicks > 0')
  .fetch(query)
  .apply()
  .notify()
)
  1. Advanced use case - use custom fetcher.
from bach import Bach

from bach.fetchers import placement_fetcher

(
  bach
  .with_fetcher(placement_fetcher.PlacementFetcher())
  .with_accounts(ACCOUNT_ID)
  .add_rules('clicks > 0')
  .fetch()
  .apply()
  .notify()
)
  1. Running a task.
from bach import Bach, tasks


task = tasks.Task(
  name='test_task',
  type='campaign_performance',
  customer_ids=ACCOUNT_ID,
  rule_expression='clicks > 1',
  extra_info={'campaign_type': 'DISPLAY'},
)

bach.run_task(task)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bach_googleads-0.0.0.tar.gz (21.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bach_googleads-0.0.0-py3-none-any.whl (34.0 kB view details)

Uploaded Python 3

File details

Details for the file bach_googleads-0.0.0.tar.gz.

File metadata

  • Download URL: bach_googleads-0.0.0.tar.gz
  • Upload date:
  • Size: 21.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.4

File hashes

Hashes for bach_googleads-0.0.0.tar.gz
Algorithm Hash digest
SHA256 d30bfe2afe41bf7711f59566fe21e3f789656e7fa012de6fcd168ba6ee1444f9
MD5 55c8d0f60d792e20439b4a796bb5e4cb
BLAKE2b-256 b05a8e97a88f0eee988e287dbb2d69dad57a9ccd7abd485e4df8b9a61e333255

See more details on using hashes here.

File details

Details for the file bach_googleads-0.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for bach_googleads-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c6583558c09252b4423b6d439baec88211c40911d594abb8946201768a984aea
MD5 f593b981f1d93dc8aa5a7bdf411d3c74
BLAKE2b-256 0b82c037e22e322ae0525ddaec0aad976095130a67770db530378b3ab1538217

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page