LeadFormAsset creation, LeadFormCustomQuestionField problem

364 views
Skip to first unread message

Anna Lysak

unread,
Sep 5, 2022, 7:08:47 AM9/5/22
to Google Ads API and AdWords API Forum
Hi Google team,

could you please help me to resolve issue. I create lead from asset using REST API : 
params = {
"operations": [{
"create": {
"name": "My Lead Form #1234",
"type": "LEAD_FORM",
...
"leadFormAsset": {
     ...
    "customQuestionFields": [
     {
            "customQuestionText": "Do you own a car?",
            "singleChoiceAnswers": {"answers": ["good", "bad", "normal"]}
      },
      {
            "customQuestionText": "Your phonenumber?",
            "singleChoiceAnswers": {"answers": ["good", "bad", "normal"]}
       }],
...
}

}
}],
}

Issue is with CustomQuestionsFields, when I try to post the data, I receive error:
 {
    "error": {
        "code": 400,
        "message": "Request contains an invalid argument.",
        "status": "INVALID_ARGUMENT",
        "details": [
            {
                "@type": "type.googleapis.com/google.ads.googleads.v11.errors.GoogleAdsFailure",
                "errors": [
                    {
                        "errorCode": {
                            "fieldError": "INVALID_VALUE"
                        },
                        "message": "The field's value is invalid.",
                        "location": {
                            "fieldPathElements": [
                                {
                                    "fieldName": "operations",
                                    "index": 0
                                },
                                {
                                    "fieldName": "create"
                                },
                                {
                                    "fieldName": "lead_form_asset"
                                },
                                {
                                    "fieldName": "custom_question_fields",
                                    "index": 0
                                },
                                {
                                    "fieldName": "custom_question_text"
                                }
                            ]
                        }
                    },
                    {
                        "errorCode": {
                            "fieldError": "INVALID_VALUE"
                        },
                        "message": "The field's value is invalid.",
                        "location": {
                            "fieldPathElements": [
                                {
                                    "fieldName": "operations",
                                    "index": 0
                                },
                                {
                                    "fieldName": "create"
                                },
                                {
                                    "fieldName": "lead_form_asset"
                                },
                                {
                                    "fieldName": "custom_question_fields",
                                    "index": 1
                                },
                                {
                                    "fieldName": "custom_question_text"
                                }
                            ]
                        }
                    }
                ],
                "requestId": "N-OnfIPCBTNTzC2N4etRtg"
            }
        ]
    }
}

From the documentation its regular string https://developers.google.com/google-ads/api/rest/reference/rest/v11/Asset#LeadFormCustomQuestionField, why that string value is incorrect - I don't have the idea. 

Could you please help me ?
Thanks.

Google Ads API Forum Advisor

unread,
Sep 5, 2022, 9:23:08 AM9/5/22
to gann...@gmail.com, adwor...@googlegroups.com
Hi Anna,

Thank you for reaching out to us.

Upon seeing your provided logs, I noticed that this is not completed. That said, could you provide us with the complete API logs  (request and response with request-id) generated on your end so our team can further investigate and provide appropriate recommendations to your concern?

Since you said that you are using the REST API, you can enable logging via the curl command by using the -i flag. This will cause the tool to include the HTTP response headers in the output.

You may then send the requested information via the Reply privately to author option. If this option is not available, you may send the details directly to our googleadsa...@google.com alias instead.

Best regards,
Google Logo
Heidi
Google Ads API Team
 
​​​​​

ref:_00D1U1174p._5004Q2dvTj4:ref
Message has been deleted
Message has been deleted

Google Ads API Forum Advisor

unread,
Sep 5, 2022, 1:53:28 PM9/5/22
to gann...@gmail.com, adwor...@googlegroups.com
Hi Anna,

Thank you for the reply.

I had to delete your post since complete logs posted on the forum. For the reference, you may refer to below without sensitive information:

URL was: https://googleads.googleapis.com/v11/customers/XXXXX/assets:mutate

"requestId": "XXXXXX" - this is request ID from the previous request

I run another request with the same data:

Full request is: XXXX Full Response is this:
{
XXXXXX
}
Response headers:


Moving forward, upon checking your provided logs, I can confirm that the format you have used is correct. That said, allow me to raise this issue to my team for further checking. Rest assured that we will provide updates when they become available.

Anna Lysak

unread,
Sep 6, 2022, 3:02:29 AM9/6/22
to Google Ads API and AdWords API Forum
Thanks, Heidi,
I will be looking forward to your reply when the issue is fixed, because we need custom questions.

Anna Lysak

unread,
Sep 7, 2022, 4:22:19 AM9/7/22
to Google Ads API and AdWords API Forum
Hi Heidi,

Do you have any updates on this?
Thanks.

Google Ads API Forum Advisor

unread,
Sep 7, 2022, 10:34:47 AM9/7/22
to gann...@gmail.com, adwor...@googlegroups.com
Hello Anna,

Heidi looped me in on this. I've checked on this as well, and I don't see a root cause, so I've reached out to one of my fellow engineers who wrote the code. I'm waiting to hear back from him.

Best,
Google Logo
Nadine Wang
Google Ads API Team
 


ref:_00D1U1174p._5004Q2dvTj4:ref

Anna Lysak

unread,
Sep 7, 2022, 11:14:07 AM9/7/22
to Google Ads API and AdWords API Forum
Thank you, waiting for your reply

Anna Lysak

unread,
Sep 7, 2022, 11:33:33 AM9/7/22
to Google Ads API and AdWords API Forum
I also have another question, just in case,
Is there a solution to add CONSENT (OPT-IN) question (yes/no or true/false) and TERMS question (yes/no or true/false) not only having them in CustomQuestions fields, may be you have something like this already which is not documented?
Thanks in advance.

Google Ads API Forum Advisor

unread,
Sep 7, 2022, 11:59:39 AM9/7/22
to gann...@gmail.com, adwor...@googlegroups.com
Hello Anna,

I don't believe that's supported yet, but I have sent it to the team working on this as a feature request.

Anna Lysak

unread,
Sep 12, 2022, 3:46:47 AM9/12/22
to Google Ads API and AdWords API Forum
Hi Nadine,

Do you have any updates on this issue? Its very important for us 
Thanks.

Google Ads API Forum Advisor

unread,
Sep 12, 2022, 1:56:53 PM9/12/22
to gann...@gmail.com, adwor...@googlegroups.com
Hello Anna,

I do have an answer. It turns out that there is a pre-defined list of approved custom questions. Strangely, the sample one is not one of them. I've asked the folks who work on the code to fix the documentation on that.

In the meantime, if you need a list of questions, I've found a way to get the pre-defined list. You can go to the Google Ads UI to get it.
  • Click on a campaign that is set up for lead forms. 
  • Under 'Ads and Extensions', click 'Extensions'.
  • Then, click the '+' to create a new extension.
  • On the page, you can either create an extension using an existing extension or a new extension. Click 'Create new'.
  • Scroll down until you see a button that says '+ Question'. Click on that.
  • You can then start typing in the search box words that you would like to use and all approved questions will come up.
  • Heres's an example where I typed 'own a vehicle', and 'Do you own a vehicle?' came up as an approved question.

Image_2022-09-12_13-49-51.png

It appears it may be possible to propose new questions through the UI as well. There is an API feature request of searching for these kinds of questions. I don't know the plans as to when it will be available, but in the meantime, this is a workaround to allow you to search for questions that you can then use in the API.

Anna Lysak

unread,
Sep 14, 2022, 3:10:49 AM9/14/22
to Google Ads API and AdWords API Forum
Why this is marked as abuse? It has been marked as abuse.
Report not abuse
Hi Nadine!
Thanks for the answer! 

But my question was about a bit different thing, how can I add custom question through API? I didn't find question related to Would you like to receive news from our company? and Agree with terms and conditions? in predefined questions list from Google.
So I wanted to create new custom question (it should be possible through API https://developers.google.com/google-ads/api/rest/reference/rest/v11/Asset?hl=en#LeadFormCustomQuestionField ):
params = {
"operations": [{
"create": {
"name": "My Lead Form #12345",
"type": "LEAD_FORM",
"final_urls": ["https://xxxxxxx.com"],
"leadFormAsset": {
"businessName": "Cats LTD",
"callToActionType": "LEARN_MORE",
"callToActionDescription": "Learn more",
"headline": "New Test Lead Form2",
"description": "New Test Lead Form description",
"privacyPolicyUrl": "https://XXX.com/en/privacy-policy/",
"fields": [
{
"inputType": "EMAIL"
},
{
"inputType": "FIRST_NAME"
},
{
"inputType": "LAST_NAME"
},
{
"inputType": "PHONE_NUMBER"
},
{
"inputType": "COUNTRY"
},
],
"customQuestionFields": [
{
"customQuestionText": "Would you like to receive news from our company?",
"singleChoiceAnswers": {"answers": ["yes", "no"]}
},
{
"customQuestionText": "Do you agree with Terms and Conditions?",
"singleChoiceAnswers": {"answers": ["yes", "no"]}
}
],
"postSubmitCallToActionType": "VISIT_SITE",
"desiredIntent": "LOW_INTENT",
"postSubmitHeadline": "Thank you!",
"postSubmitDescription": "Thanks for filling Lead Form",

}

}
}],
}
url is https://googleads.googleapis.com/v11/customers/XXXXXX/assets:mutate

And I get response that custom question string is incorrect:
                "requestId": "286AZG9PkOP0sdKWh1S_TA"
            }
        ]
    }
}

Google team said in above responses that my request is formed correctly, and its possible to add new custom questions, that are not in the predefined questions list.

2. Second issue: I can update Lead Form fileds like name, descriptions, But I can't update 'fields' (questions) - I can't add or delete question:
params = {
"operations": [{
"updateMask": "name,leadFormAsset.businessName,leadFormAsset.headline,fields",
"update": {
"resourceName": "customers/XXXXX/assets/XXXX",
"name": "My Lead Form #123456",
"type": "LEAD_FORM",
"final_urls": ["https://xxxx.com"],
"leadFormAsset": {
"businessName": "Cats LTD New",
"callToActionType": "LEARN_MORE",
"callToActionDescription": "Learn more",
"headline": "New Test Lead Form23",
"description": "New Test Lead Form description",
"privacyPolicyUrl": "https://xxxx.com/en/privacy-policy/",
"fields": [
{
"inputType": "EMAIL"
},
{
"inputType": "FIRST_NAME"
},
{
"inputType": "LAST_NAME"
},
{
"inputType": "PHONE_NUMBER"
},
{
"inputType": "COUNTRY"
},
{
"inputType": "CITY"
},
"postSubmitCallToActionType": "VISIT_SITE",
"desiredIntent": "LOW_INTENT",
"postSubmitHeadline": "Thank you!",
"postSubmitDescription": "Thanks for filling Lead Form",

}

}
}],
}

I wanted to add {
"inputType""CITY"
},   to lead form fields, but I receive error:

 {
    "error": {
        "code": 400,
        "message": "Request contains an invalid argument.",
        "status": "INVALID_ARGUMENT",
        "details": [
            {
                "@type": "type.googleapis.com/google.ads.googleads.v11.errors.GoogleAdsFailure",
                "errors": [
                    {
                        "errorCode": {
                            "fieldMaskError": "FIELD_NOT_FOUND"
                        },
                        "message": "The field mask contained an invalid field: 'fields'.",

                        "location": {
                            "fieldPathElements": [
                                {
                                    "fieldName": "operations",
                                    "index": 0
                                }
                            ]
                        }
                    }
                ],
                "requestId": "Crb5x0gGv5ZZs1C4Xzlxaw"
            }
        ]
    }
}

What is the way to update (add/remove) lead form fields? I need API request example, please?

Thanks in advance!
Anna.

Google Ads API Forum Advisor

unread,
Sep 14, 2022, 1:20:43 PM9/14/22
to gann...@gmail.com, adwor...@googlegroups.com
Hello Anna,

Thank you for taking the time to clarify. Sadly, there isn't a way of creating new custom questions through the API. That's a feature request that the lead forms engineers are looking at adding to the API. I don't have a timeline for that feature, yet. You can only use existing custom questions through the API, which is why I provided how you can get that list. Currently, you can propose new questions through the UI and then use those questions once approved in the API. So, I recommend doing that if you do not see that in the existing question bank.

Regards,

Anna Lysak

unread,
Sep 15, 2022, 6:15:13 AM9/15/22
to Google Ads API and AdWords API Forum
Hi Nadine,
Thank you for the answer, I created 2 questions via New question request via the UI. They are:
"Would you like to receive news? (yes/no)"  and
"Do you agree with Terms and Conditions? (yes/no)"

When do I suppose to get the codes for them in documentation? https://developers.google.com/google-ads/api/rest/reference/rest/v11/LeadFormFieldUserInputType 

Thanks. 

Anna Lysak

unread,
Sep 15, 2022, 6:22:33 AM9/15/22
to Google Ads API and AdWords API Forum
Also I have the question: 
I see that "Would you like to receive the latest updates?" appears in UI in list of questions, but I don't see it in https://developers.google.com/google-ads/api/rest/reference/rest/v11/LeadFormFieldUserInputType  to be able to use it from API. Can your team please update the documentation related to all new questions? 
Thanks.

Google Ads API Forum Advisor

unread,
Sep 15, 2022, 9:33:08 AM9/15/22
to gann...@gmail.com, adwor...@googlegroups.com
Hello Anna,

I believe those do not become questions in LeadFormFieldUserInputType. When those questions are accepted questions, I believe you can then use them in the custom questions field. Have you tried putting them in the custom questions field in the API after they are accepted questions in the UI? If that doesn't work, please give me a heads-up, and then I can check on that.
Reply all
Reply to author
Forward
0 new messages