Posts tagged with google-ads-script

I have generated developer_token, access_token and refresh token with googleads read permission. While using in code using google-ads-api I am getting below error.

Code:

from google.ads.googleads.client import GoogleAdsClient googleads_client = GoogleAdsClient.load_from_storage(path="./googleads.yaml", version="v14") 

Error:

  googleads_client = GoogleAdsClient.load_from_storage(path="./googleads.yaml", version="v14") 

I followed this tutorial to generate developer token, access token and refresh_token.

Here is permissions in the app and during authorization screenshot

I am running ad campaigns and I want to track the performance of users I acquire through those ads.

With the user data I get the gclid , I want to map this gclid with the campaign name or campaign id.

How can I do this?

I've build a own tracking template for Google ads, which looks like this:

http://tracking.example.com?lpurl={lpurl}

This tracking link (where {lpurl} is the final url) leads to our website and triggers the script below.

<?php     header("Status: 301 Moved Permanently"); // some code to add data to our database // then redirect traffic to url:     header("Location:".$_GET["lpurl"]."?". $_SERVER['QUERY_STRING']);     exit; ?> 

I have started using ClickPatrol.com for click fraud protection and PPC protection. However, they also require a tracking template. They work well with Hubspot, but I don't know how to combine their tracking template with mine and modify my script.

their trackingtemplate is: https://example.com/?uid=[unique id]&adp={adposition}&lpm={loc_physical_ms}&lim={loc_interest_ms}&adi={adgroupid}&k={keyword}&n={network}&ci={campaignid}&d={device}&p={placement}&u={lpurl}&ma={matchtype}&ta={target}&cr={creative}

Any idea how I can combine:

http://example.com?url={lpurl}

and

https://example.com/?uid=[unique id]&adp={adposition}&lpm={loc_physical_ms}&lim={loc_interest_ms}&adi={adgroupid}&k={keyword}&n={network}&ci={campaignid}&d={device}&p={placement}&u={lpurl}&ma={matchtype}&ta={target}&cr={creative}

I want to track my traffic with my own script and also use ClickPatrol

I attempted to merge the querystring and redirect it, but the urls in the querystring made it difficult to decode and encode, resulting in redirecting errors.

I'm trying to send a google ads measurement conversion purchase event from my python backend.

I have the correct conversion lable and id.

class GoogleAds(Analytic): def __init__(self, data, shop_unique_id, event):     self.base_url = "https://www.googleadservices.com/pagead/conversion/{conversion_id}/"     super().__init__(data, shop_unique_id, event) def send_google_ads_event(self, payload):     try:         label = "label"         conversion_id = "id"         # for market in self.profile.markets:         #     if market_domain == market.domain:         #         ga4_measurement_id = market.ga4_measurement_id         #         ga4_api_secret = market.ga4_api_secret         if (             label != ""             and label is not None             and conversion_id != ""             and conversion_id is not None         ):             payload['conversion_id'] = conversion_id             payload['label'] = label             response = requests.get(self.base_url.format(conversion_id=conversion_id), params=payload)         # Check if the conversion was registered successfully         if response.status_code == 200 and response.headers.get('Content-Type') == 'image/gif':             log.info(                 "Finished sending data to Google ads",                 extra={                     "url": response.request.url,                     "sending_params": payload,                     "response_content_type": response.headers.get('Content-Type'),                     "status_code": response.status_code,                 },             )             return True         else:             log.error("Failed to send data to Google ads", extra={"status_code": response.status_code})             return False     except requests.RequestException as e:         log.error(f"Error sending data to Google ads: {e}")         return False 

This request returns status code 200, but on google ads measurements ui the count is still 0.

Payload looks like this

def purchase_data(webhook_data, shop_unique_id): transformed_items = [{     "id": item["product_id"],     "price": item["price"],     "quantity": item["quantity"] } for item in webhook_data["line_items"]] data = dict(     label="label",     value=float(webhook_data["total_price"]),     currency_code=webhook_data["currency"],     transaction_id=webhook_data["id"],     conversion_id="conversion_id",     items=transformed_items,     feed_country="GB",     merchant_id="merchant_id",     feed_language="GB" ) return data 

Any idea why that could be happening?

I deployed inside a docker a reactjs project (optimized build).

I added the required scripts to enable Google ADS but I got following message

It doesn't find the ads.txt file, I put it under the /public folder and re-built and re-deployed the docker but nothing.. do you have any suggestion for it?