Hi all.

I'm trying to upload offline conversion but I get the following partial 
error message:

"This customer does not have an import conversion action that matches the 
conversion action provided., at conversions[0].conversion_action"

In attachment I share the snippet of code. 

In the method "upload" there is the first parameter "mcc_id" with which I 
have developer token

The second parameter is "customer_id" with which I have to upload conversion

For clarify I share also the hierarchy in Google Manager Ads

[image: hierarchy_google (2).png] 

In the code use mcc_id to upload conversion while I use customer_id to get 
click_conversion and click_action. Is that correct ? 

My question is if to solve that error I have to upload conversion using the 
account master MCC(So I have to activate another developer token) or is 
better to use the conversion action inherited by agency MCC ?
Any help is appreciated.

Best regards,
Andrea


-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/9f727d7f-540e-4935-a016-df02852bb968n%40googlegroups.com.
def query(customer_id, client, page_size=100):

    ga_service = client.get_service("GoogleAdsService", version="v5")

    query =  """SELECT 
                    conversion_action.id,
                    conversion_action.name,
                    conversion_action.owner_customer, 
                    conversion_action.type 
                FROM conversion_action
                WHERE conversion_action.type = 'WEBPAGE' """

    response = ga_service.search(customer_id, query, page_size=page_size)
    return response

def upload(mcc_id, customer_id, gclid, conversion_date_time, conversion_value):

    # GoogleAdsClient will read the google-ads.yaml configuration file in the
    # home directory if none is specified.
    # print("get clients for country {} and customer_id {}".format(country, customer_id))
    #storage = "resources/google-ads-{}-{}.yaml".format(country, customer_id)
    storage = "resources/google-ads.yaml"
    google_ads_client = GoogleAdsClient.load_from_storage(storage)

    """Creates a click conversion with a default currency of USD."""

    click_conversion = google_ads_client.get_type("ClickConversion", version="v5")
    conversion_action_service = google_ads_client.get_service(
        "ConversionActionService", version="v5"
    )

    response = query(customer_id, google_ads_client)

    for row in response:
        click_conversion.conversion_action = conversion_action_service.conversion_action_path(
            customer_id, row.conversion_action.id
        )
        click_conversion.gclid = gclid
        click_conversion.conversion_value = float(conversion_value)
        click_conversion.conversion_date_time = conversion_date_time
        click_conversion.currency_code = "EUR"
        conversion_upload_service = google_ads_client.get_service(
            "ConversionUploadService", version="v5"
        )

        try:
            conversion_upload_response = conversion_upload_service.upload_click_conversions(
                mcc_id, [click_conversion], partial_failure=True
            )
            uploaded_click_conversion = conversion_upload_response.results[0]
            print(
                f"Uploaded conversion that occurred at "
                f'"{uploaded_click_conversion.conversion_date_time}" from '
                f'Google Click ID "{uploaded_click_conversion.gclid}" '
                f'to "{uploaded_click_conversion.conversion_action}"')
        except GoogleAdsException as ex:
            print(
                f'Request with ID "{ex.request_id}" failed with status '
                f'"{ex.error.code().name}" and includes the following errors:')
            for error in ex.failure.errors:
                print(f'\tError with message "{error.message}".')
                if error.location:
                    for field_path_element in error.location.field_path_elements:
                        print(f"\t\tOn field: {field_path_element.field_name}")
            sys.exit(1)

Reply via email to