Ejemplo n.º 1
0
    AdSet.Field.daily_budget: 1000,
    AdSet.Field.billing_event: AdSet.BillingEvent.impressions,
    AdSet.Field.optimization_goal: AdSet.OptimizationGoal.reach,
    AdSet.Field.bid_amount: 2,
    AdSet.Field.targeting: {
        TargetingSpecsField.geo_locations: {
            'countries': ['US'],
        },
    },
    AdSet.Field.status: AdSet.Status.paused,
})

adset.remote_create()
print(adset)
# _DOC close [ADSET_CREATE]
adset.remote_delete()



# _DOC open [ADSET_CREATE_APP_CONNECTIONS_TARGETING]
# _DOC vars [ad_account_id:s, campaign_group_id, connections_id]
from facebookads.objects import AdSet, TargetingSpecsField

ad_set = AdSet(parent_id=ad_account_id)
ad_set.update({
    AdSet.Field.name: 'Android Connections Targeting - Ad Set',
    AdSet.Field.campaign_group_id: campaign_group_id,
    AdSet.Field.optimization_goal: AdSet.OptimizationGoal.post_engagement,
    AdSet.Field.billing_event: AdSet.BillingEvent.post_engagement,
    AdSet.Field.bid_amount: 1500,
    AdSet.Field.daily_budget: 10000,
                    },
                },
            ],
        },
    ],
    TargetingSpecsField.excluded_product_audience_specs: [
        {
            'product_set_id': product_set_id,
            'inclusions': [
                {
                    'retention_seconds': 259200,
                    'rule': {
                        'event': {
                            'eq': 'ViewContent',
                        },
                    },
                },
            ],
        },
    ],
}
adset[AdSet.Field.promoted_object] = {
    'product_set_id': product_set_id,
}
adset[AdSet.Field.product_ad_behavior] = 'FALL_BACK_TO_FB_RECOMMENDATIONS'

adset.remote_create()
# _DOC close [ADSET_CREATE_PRODUCT_CATALOG_SALES_VIEWED_DAYS_RETENTION]

adset.remote_delete()
                'id': 6002714895372,
                'name': 'All travelers',
            },
        ],
        TargetingSpecsField.life_events: [
            {
                'id': 6002714398172,
                'name': 'Newlywed (1 year)',
            },
        ],
        TargetingSpecsField.home_ownership: [
            {
                'id': 6006371327132,
                'name': 'Renters',
            },
        ],
        TargetingSpecsField.page_types: [
            'desktopfeed',
            'rightcolumn',
            'mobilefeed',
            'mobileexternal',
        ],
    },
})
ad_set.remote_create(params={
    'status': AdSet.Status.paused,
})
# _DOC close [ADSET_CREATE_ADS_MANAGEMENT_UI]

ad_set.remote_delete()