# You are hereby granted a non-exclusive, worldwide, royalty-free license to # use, copy, modify, and distribute this software in source code or binary # form for use in connection with the web services and APIs provided by # Facebook. # As with any software that integrates with the Facebook platform, your use # of this software is subject to the Facebook Developer Principles and # Policies [http://developers.facebook.com/policy/]. This copyright notice # shall be included in all copies or substantial portions of the software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. from examples.docs import fixtures ad_label_id = fixtures.create_adlabel().get_id() # _DOC open [ADLABEL_DELETE] # _DOC vars [ad_label_id] from facebookads.objects import AdLabel adlabel = AdLabel(ad_label_id) adlabel.remote_delete() # _DOC close [ADLABEL_DELETE]
ad_account = AdAccount(ad_account_id) params = { 'level': 'adgroup', 'filtering': [{ 'field': 'adgroup.delivery_info', 'operator': 'IN', 'value': ['archived'] }] } stats = ad_account.get_insights(params=params) print(stats) # _DOC close [ADACCOUNT_GET_INSIGHTS_FILTERING_DELIVERY_INFO_LEVEL] ad_label_name = fixtures.create_adlabel()[AdLabel.Field.name] # _DOC open [ADACCOUNT_GET_INSIGHTS_FILTERING_ADLABEL_NAMES] # _DOC vars [ad_account_id:s, ad_label_name:s] from facebookads.objects import AdAccount, Insights ad_account = AdAccount(ad_account_id) params = { 'fields': [ Insights.Field.clicks, Insights.Field.cpc, Insights.Field.total_actions ], 'level': 'adgroup', 'filtering': [{ 'field': 'adgroup.adlabels',
ad_account = AdAccount(ad_account_id) params = { 'level': 'adgroup', 'filtering': [{ 'field': 'adgroup.delivery_info', 'operator': 'IN', 'value': ['archived'] }] } stats = ad_account.get_insights(params=params) print(stats) # _DOC close [ADACCOUNT_GET_INSIGHTS_FILTERING_DELIVERY_INFO_LEVEL] ad_label_name = fixtures.create_adlabel()[AdLabel.Field.name] # _DOC open [ADACCOUNT_GET_INSIGHTS_FILTERING_ADLABEL_NAMES] # _DOC vars [ad_account_id:s, ad_label_name:s] from facebookads.objects import AdAccount, Insights ad_account = AdAccount(ad_account_id) params = { 'fields': [Insights.Field.clicks, Insights.Field.cpc, Insights.Field.total_actions], 'level': 'adgroup', 'filtering': [{ 'field': 'adgroup.adlabels', 'operator': 'ANY', 'value': [ad_label_name]
# Policies [http://developers.facebook.com/policy/]. This copyright notice # shall be included in all copies or substantial portions of the software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. from examples.docs import fixtures from facebookads import test_config from facebookads.objects import AdLabel ad_account_id = test_config.account_id ad_label_name = fixtures.create_adlabel()[AdLabel.Field.name] # _DOC open [ADACCOUNT_GET_INSIGHTS_FILTERING_ADLABEL_NAMES] # _DOC vars [ad_account_id:s, ad_label_name:s] from facebookads.objects import AdAccount, Insights ad_account = AdAccount(ad_account_id) params = { 'fields': [ Insights.Field.unique_clicks, Insights.Field.ctr, Insights.Field.total_actions ], 'level': 'ad', 'filtering': [{ 'field': 'ad.adlabels',
adgroup = AdGroup(ad_group_id) adgroup.remote_archive() # _DOC close [ADGROUP_ARCHIVE] # _DOC open [ADGROUP_GET_ADLABELS] # _DOC vars [ad_group_id] from facebookads.objects import AdGroup adgroup = AdGroup(ad_group_id) adgroup.get_ad_labels() # _DOC close [ADGROUP_GET_ADLABELS] ad_label = fixtures.create_adlabel() ad_label_id = ad_label.get_id() ad_group_id = fixtures.create_adgroup().get_id() # _DOC open [ADGROUP_UPDATE_LABELS] # _DOC vars [ad_group_id, ad_label_id] from facebookads.objects import AdGroup adgroup = AdGroup(ad_group_id) adgroup[AdGroup.Field.adlabels] = [ {AdLabel.Field.id: ad_label_id}, {AdLabel.Field.name: 'New Label Name'}, ] adgroup.remote.update() # _DOC close [ADGROUP_UPDATE_LABELS]
# _DOC vars [ad_group_id] from facebookads.objects import AdGroup adgroup = AdGroup(ad_group_id) adgroup.remote_archive() # _DOC close [ADGROUP_ARCHIVE] # _DOC open [ADGROUP_GET_ADLABELS] # _DOC vars [ad_group_id] from facebookads.objects import AdGroup adgroup = AdGroup(ad_group_id) adgroup.get_ad_labels() # _DOC close [ADGROUP_GET_ADLABELS] ad_label = fixtures.create_adlabel() ad_label_id = ad_label.get_id() ad_group_id = fixtures.create_adgroup().get_id() # _DOC open [ADGROUP_UPDATE_LABELS] # _DOC vars [ad_group_id, ad_label_id] from facebookads.objects import AdGroup adgroup = AdGroup(ad_group_id) adgroup[AdGroup.Field.adlabels] = [ { AdLabel.Field.id: ad_label_id }, { AdLabel.Field.name: 'New Label Name' },