R
Ritesh Chauhan
Guest
I'm trying to send a google ads measurement conversion purchase event from my python backend.
I have the correct conversion lable and id.
This request returns status code 200, but on google ads measurements ui the count is still 0.
Payload looks like this
Any idea why that could be happening?
<p>I'm trying to send a google ads measurement conversion purchase event from my python backend.</p>
<p>I have the correct conversion lable and id.</p>
<pre><code>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
</code></pre>
<p>This request returns status code 200, but on google ads measurements ui the count is still 0.</p>
<p>Payload looks like this</p>
<pre><code>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
</code></pre>
<p>Any idea why that could be happening?</p>
Continue reading...
I have the correct conversion lable and id.
Code:
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
Code:
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?
<p>I'm trying to send a google ads measurement conversion purchase event from my python backend.</p>
<p>I have the correct conversion lable and id.</p>
<pre><code>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
</code></pre>
<p>This request returns status code 200, but on google ads measurements ui the count is still 0.</p>
<p>Payload looks like this</p>
<pre><code>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
</code></pre>
<p>Any idea why that could be happening?</p>
Continue reading...