Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Where do I get the placement and site_source_name values in the SDK? #671

Open
edpruuv opened this issue Jun 7, 2024 · 6 comments
Open

Comments

@edpruuv
Copy link

edpruuv commented Jun 7, 2024

Given this url tag placement={{placement}} site_source_name={{site_source_name}}

Where do I get these values using the SDK?

Which specific field in the following to they belong?

Campaign.Field
AdSet.Field
Ad.Field

I tried the following:

`

CAMPAIGN_FIELDS = [
Campaign.Field.account_id,
Campaign.Field.id,
Campaign.Field.name,
Campaign.Field.budget_remaining,
Campaign.Field.objective,
]
connection = AdAccount(customer_id)

params = {

        "breakdowns": [
            "impression_device",
            "publisher_platform",
            "device_platforms",
            "platform_position",
        ],
    }

campaigns = connection.get_campaigns(fields=fields, params=params)

`

But all I get is this output:

{ "account_id": "1**705********1241", "budget_remaining": "0", "id": "120208422448000423", "name": "Creative and Audience Test", "objective": "OUTCOME_LEADS" }

Should I go for the Adset or Ad level?

Please help!

@Just1B
Copy link

Just1B commented Jun 7, 2024

Hi @edpruuv 👋

When you run, your example below -> you are requesting the endpoint {ad-account-id}/campaigns

https://developers.facebook.com/docs/marketing-api/reference/ad-campaign-group/#fields

connection = AdAccount(customer_id)

campaigns = connection.get_campaigns(fields=fields, params=params)

I think you misunderstood the breakdowns parts witch is related to the insights

🛑 All breakdowns are not always compatible with each others ( combining breakdowns )

# {ad-account-id}/insights

account = AdAccount("act_" + self.account_id)

insights = account.get_insights(
    fields= [ "account_id", .... , "clicks", "impressions", "spend" ... ]
    params={
        "use_unified_attribution_setting": True,
        "breakdowns": [
            "publisher_platform",
            "platform_position",
            "impression_device",
        ],
        "level": "ad",
        "time_increment": 1,
        "time_range": {
            "since": XYZ,
            "until": XYZ,
        },
    },
    is_async=True,
)

insights.api_get()

@edpruuv
Copy link
Author

edpruuv commented Jun 7, 2024

Thanks a ton @Just1B !

I will try this now.
This is my first time working with facebook marketing api.

Your comment is greatly appreciated!
I'll give a feedback once I tried it out.

Cheers!

@edpruuv
Copy link
Author

edpruuv commented Jun 7, 2024

I got the folowing insight data @Just1B

insight_data = {'ad_id': '2386******17828250422', 'ad_name': 'A***', 'adset_id': '238622**', 'campaign_id': '238**21**260422', 'clicks': '0', 'cpm': '0', 'ctr': '0', 'date_start': '2024-06-07', 'date_stop': '2024-06-07', 'impression_device': 'iphone', 'impressions': '1', 'platform_position': 'search', 'publisher_platform': 'facebook', 'spend': '0'}

My next(and main) question is what breakdown parameter should I pass to get the value of these dynamic variables in the url tag:

{{placement}}

{{site_source_name}}

image

Specifications for URL dynamic parameters link:
https://www.facebook.com/business/help/2360940870872492

What am I missing here?

P.S. You're response is greatly appreciated

@edpruuv
Copy link
Author

edpruuv commented Jun 7, 2024

We already have url_tags but the dynamic url parameters are not being replaced automatically

utm_source=facebook&utm_medium={{site_source_name}}&utm_campaign={{placement}}&utm_content={{ad.id}}

That's why I need to find where I can get the site_source_name and placement value

Please advice.

Thank you

image

@fernando-heitor
Copy link

Hey @edpruuv how's it going?

Were you able to find any solution to this problem? I'm facing the same issue that you mentioned

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants