creating ConversionActions with Java googleads.v14

73 views
Skip to first unread message

Marc Donis

unread,
Jul 19, 2023, 10:29:35 AM7/19/23
to Google Ads API and AdWords API Forum
I'm basing my development on this code example, but I'm having some trouble creating and configuring ConversionActions.

The docs here say this:

Website and Phone number clicks conversions require the event_snippet (which should be placed on web pages that indicate a conversion action such as a checkout confirmation or lead submission page) and global_site_tag (which must be installed on every page of your website). You can retrieve both of these attributes with ConversionActionService.

Unfortunately, the linked ConversionActionService docs make no mention of either of these fields. I did find a getTagSnippetsList() method which I can call on my newly created ConversionAction, but this returns an empty list.

How can I get the Google Tag ID, or the complete snippet code to be inserted into the web page?

Another question:
How to configure the conversion URL? The UI provides fields to set the match type (e.g., "URL contains") and the URL of the conversion page, but I can find no reference to these fields in the docs.

Thanks for any help.

Google Ads API Forum Advisor

unread,
Jul 19, 2023, 1:08:31 PM7/19/23
to adoni...@gmail.com, adwor...@googlegroups.com

Hello,

Thanks for reaching out to the Google Ads API Team.

With regards to the event_snippet and global_site_tag please refer to this API documentation links.

How can I get the Google Tag ID, or the complete snippet code to be inserted into the web page?

How to configure the conversion URL? The UI provides fields to set the match type (e.g., "URL contains") and the URL of the conversion page, but I can find no reference to these fields in the docs.

  • Can you please provide us with an uncropped screenshot of this view in the Google Ads UI, so we can provide precise guidance and recommendations?
This message is in relation to case "ref:_00D1U1174p._5004Q2n9Sfa:ref"

Thanks,
 
Google Logo Google Ads API Team


Marc Donis

unread,
Jul 20, 2023, 4:43:08 AM7/20/23
to Google Ads API and AdWords API Forum
I just sent a reply, but it seems to have vanished. Sorry if this is a duplicate....

Regarding obtaining the TagSnippet and/or tag ID:
We are aware of the docs you indicated. Like I said, the issue is that ConversionAction.getTagSnippetsList() method returns an empty list for a newly created ConversionAction. Can you please explain how to generate the TagSnippet?

This link which you provided describes how to configure tags manually, using the user interface, but this is not useful for us. We would need to be able to do this via the Java API. I hesitate to contact Google Ads Product Support, as you suggest, since I don't think they will have any knowledge about API usage.

Regarding configuration of the conversion URL:
Here is the complete screenshot you requested.
google conversion action details.png

Google Ads API Forum Advisor

unread,
Jul 20, 2023, 8:10:45 AM7/20/23
to adoni...@gmail.com, adwor...@googlegroups.com
Hello Marc,

With regards to ConversionAction.getTagSnippetsList(), for clarification, is this from the client library? If yes, I recommend reaching out to the respective client library owner by filing an issue on the issue tracker on the Issues tab of your chosen client library on the github, so that they can provide guidance.

With regards to retrieving and configuring Google Tag ID via API, can you please provide us with an uncropped screenshot of this view in the Google Ads UI? 

Marc Donis

unread,
Jul 21, 2023, 1:32:41 AM7/21/23
to Google Ads API and AdWords API Forum
The owner of the client library on Github directed me to Google Ads API Direct Support, who has now directed me back here.

Can somebody please tell me how to get the snippet code from a newly created ConversionAction? Even just the Google Tag ID would do fine.

Here is my code:
            final ConversionAction conversionAction = ConversionAction.newBuilder()
                    .setName("ConversionAction " + new Date())
                    .setCategory(ConversionActionCategory.DEFAULT)
                    .setType(ConversionActionType.WEBPAGE)
                    .setStatus(ConversionActionStatus.ENABLED)
                    .setViewThroughLookbackWindowDays(2)
                    .setValueSettings(ValueSettings.newBuilder()
                            .setDefaultValue(conversionValue)
                            .setAlwaysUseDefaultValue(true)
                            .build())
                    .build();
            final ConversionActionOperation operation = ConversionActionOperation.newBuilder()
                    .setCreate(conversionAction).build();

            final MutateConversionActionsResponse response = conversionActionServiceClient
                    .mutateConversionActions(adAccountId, Collections.singletonList(operation));
            final MutateConversionActionResult result = response.getResultsList().get(0);
            final List<TagSnippet> tagSnippets = reloadedConversionAction.getTagSnippetsList();



At this point, tagSnippets is an empty List. What am I missing here?

Google Ads API Forum Advisor

unread,
Jul 21, 2023, 5:19:57 AM7/21/23
to adoni...@gmail.com, adwor...@googlegroups.com

Hi Marc, 

Thank you for getting back to us.

Please allow me to raise your concern to the rest of our team for further insights. We will get back to you once we have more information to share.

Reply all
Reply to author
Forward
0 new messages