Upload a Campaign with location targeting?

64 views
Skip to first unread message

Neil Turner

unread,
Apr 25, 2018, 6:50:36 PM4/25/18
to AdWords API and Google Ads API Forum
Hello,

I'm using the "Add Campaigns" script found here:
https://developers.google.com/adwords/api/docs/samples/python/basic-operations#add-campaigns

Is it possible to modify the script to set location and language targeting for the campaigns I'm uploading?
 

Peter Oliquino (AdWords API Team)

unread,
Apr 26, 2018, 1:51:08 AM4/26/18
to AdWords API and Google Ads API Forum
Hi Neil,

You would need to make a separate call using a different service when applying campaign level criteria. The AdWords API service that you can use is the CampaignCriterionService.

As for location targeting, you can refer to our geo targeting spreadsheet for the Location criteria you wish to target. You can then create your Location and Language CampaignCriterion and you can refer to this example code as to how.

Let me know if this helps.

Best regards,
Peter
AdWords API Team

Neil Turner

unread,
May 1, 2018, 1:55:58 PM5/1/18
to AdWords API and Google Ads API Forum
Perfect!
This works great. However, I'm running into an error when I try to use the same technique to include IP exclusions. Here is the code:

    # Add language & location & IP targeting from table
    for campaign in campaigns['value']:
        operations = [{
            'operator': 'ADD',
            'operand': {
                'campaignId': campaign['id'],
                'criterion': {
                    'xsi_type': 'Language',
                    'id': row['language'],
                    'xsi_type': 'Location',
                    'id': row['location'],
                    'xsi_type': 'IpBlock',
                    'ipAddress': 'row['ip']'
                }
            }
        }]
        result = campaign_criterion_service.mutate(operations)

It was working fine, until I tried to add the IP exclusion. Any suggestions?

Milind Sankeshware (AdWords API Team)

unread,
May 1, 2018, 5:37:37 PM5/1/18
to AdWords API and Google Ads API Forum
Hi Neil,

I am Peter's colleague and will be following up on this thread as he is unavailable today. Since you are trying to exclude the IP address from campaign targeting, you will need to add that as a negative campaign criteria. Please refer this sample code block. If you are still facing an issue please enable the logging and share the SOAP request and response logs. Please use reply privately to author option while sharing the logs.

Thanks,
Milind, AdWords API Team.
Reply all
Reply to author
Forward
0 new messages