How to get adCost from the new Google Analytics Data API (GA4)? - google-analytics-api

Written a script to export data from the Google Analytics Data API to MySQL. Works like a charm. Now I wanted to add adCost as a metric, but it doesn't show up in the list of metrics in the documentation. Also nothing like it (searched for things with 'spend' and 'cost'). In the old (Reporting) API it has always been available.
Doesn't Google offer this metric in the new API or is it just that it's not in the list. And if so, what would be the exact name for it?

Google announced the update this week on 19-10-2022:
On behalf of the Google Analytics team I would like to announce the following updates to the Google Analytics Data API:
New Ads metrics added to the API Schema:
advertiserAdClicks Ads clicks. Total number of times users have clicked on an ad to reach the property.
advertiserAdCost Ads cost. The total amount you paid for your ads.
advertiserAdCostPerClick Ads cost per click. Ads cost per click is ad cost
advertiserAdCostPerConversion Cost per conversion. Cost per conversion is ad cost divided by conversions.
advertiserAdImpressions Ads impressions. The total number of impressions.
returnOnAdSpend Return on ad spend. Return On Ad Spend (ROAS) is total revenue divided by advertiser ad cost.
https://groups.google.com/g/google-analytics-api-notify/c/rdmuC8IpBoQ/m/OSnFcLT9AQAJ
The new ads metrics are now also listed in the GA4 API documentation.

Related

Microsoft Bing Maps: Billable or non-Billable

I am using Microsoft Bing Maps for my mobile app project. The API which I am using is REST-Imagery Metadata. It shows on my account that it is billable after 25 hits. 490 hits have already occured. If the API is billable, how the billing is happening and what is the criteria for payment? Someone please clarify in detail.
It's buried in the Terms of Service - but you still get a certain number of "billable" transactions for free provided you're making a mobile-app, even a commercial app, if it's available for a non-Microsoft mobile device platform (i.e. Android and iOS). I imagine because it's free advertising for Bing Maps when users would otherwise be using rivals Google Maps or Apple Maps respectively.
Source: https://www.microsoft.com/en-us/maps/product
(c) Limited website and mobile app use.
If you are using the Services in an Application for commercial, non-commercial (except for Education or Non-profit use) or government use under these TOU, without entering into Standard Terms, then your Application must be available on a website or a mobile app running in a non-Microsoft Windows operating system, and must not exceed (i) 125,000 cumulative Billable Transactions (which will be free of charge) as defined in the Documentation, per calendar year or (ii) 5 queries per second, calculated as the sum of client-side and server-side queries. If your use will exceed these limits, please contact us to license additional transactions
It looks like Microsoft will deactivate your account or block further requests once you hit that limit of 125,000 transactions/year and then you'll have to register for paid access and provide payment method details.
If you are using a basic Bing maps dev account than you will get 125k free transactions per year. Those billable transaction in usage report will be billed from your free limits. You don't have to pay anything until you exhaust the free limits. I found the below text from the Bing maps documentation.
"Only billable transactions count towards the free-use limits for Basic keys, and Enterprise keys are only charged for billable transactions. Non-billable transactions do not incur charges and do not count towards free-use limits. To determine if your application will qualify for free use and for info about licensing and transaction limits, please see the Bing Maps licensing page and review the Bing Maps Terms of Use."
-Bing maps dev center

Fetching comments from active facebook ads

I am working on a Facebook comment manager and I just can't manage to get only active ad creatives from Facebook API.
Is there a way to get all ad creatives filtered by their status?
I can't afford to check all ads manually, because I plan to pull ads every few minutes and I would be hitting Facebook's rate limit.
There are a number of endpoints that could help you do this, but would require you to make multiple API calls.
Step One: Get all Ads
Assuming you have managed to get the Ad Account ID from a previous API call, you will be able to get all Ads running against that account by making a GET request to the /act_{ad_account_id}/ads?fields=name endpoint.
Step Two: Get Images with Active Status
Next you can call the /{ad_id}/adcreatives?fields=name,image_hash,status endpoint for each Ad, which will return the name of the creative, the image hash that was used, and the status of the creative.
If you require the status of the actual Ad itself rather than the status of the creative, you will need to do another step in between Step One and Step Two, where you call /{ad_id}?fields=name,status on each Ad, then filter ACTIVE campaigns.
EDIT:
You can use /act_{ad_account_id}/adcreatives?fields=status,image_hash,title to get all creatives and statuses associated with the account. This would reduce your API call rate although would mean you would need to sort the creative to match with the ads. Using the title field would give the title of the ad it was used in the ad. Facebook does not offer any other fields related to the ad itself.
You can limit results to ads whose effective_status is ACTIVE.
Here is a sample request:
act_123/ads?filtering=[{"field":"effective_status","operator":"IN","value":["PAUSED"]}]
Ad fields
Insight Parameter

Facebook Graph API | Marketing Insights - Count Shares and Likes, Haha, Love...Etc for an AD

Is it possible to get Share Count as well the actions count for likes, ahah, dislike etc via the Facebook API / Marketing insights?
So far I'm able to get this data for posts(which are related to ads if promoted), but this is a lifetime metric I can't have the numbers in a daily basis, unless I calculate it by doing the difference once I have the data.
Also, I would never now, if the likes are being made by someone who saw my post somewhere because its promoted, or if that person went directly to my page.
Is there any way to achieve this results?
If you look at the actions field in insights, you should see a field called post_reaction which is the total number of reactions for your ad in the requested timeframe.
To get a daily breakdown, use time_increment=1 and time_range to specify the date range.
I don't believe we provide breakdowns on the different reaction types however.
Docs for parameters:
https://developers.facebook.com/docs/marketing-api/insights/parameters/v2.9

Facebook Ads API managing own account rate limits

my question is simple, we need an app to manage a large amount of Facebook ads/adsets on our own single account.
Basic operations, like for example setting a daily budget for all adsets in one shot, instead of manually doing it via facebook interface.
The issue is that we are reaching the API limits pretty fast, as we can have even 50-100 adsets in one campaign. I am hitting the API limit simply by listing them sometimes.
I saw in the Facebook App advanced settings that you can add an Facebook Ad account ID, or a Business account, would that help with the limits?
Or even better, is this even possible? Handling large amount of ads? We have a big budget and all, but it's getting tedious to micromanage large amount of ads.
The rate limit per adaccount is heavier limited if you are in development than in basics. In the basics level you can also have three instead of one system users, which would probably mean (correct me if I am wrong) that you can alternate between three tokens and thus get more api calls.
It is also worth to note that updating existing ads/adsets/campaigns is 10-100 times more expensive than creating new ones. You will also get the rate limit error if you change daily budget or similar more than four times a day, so that might be a problem during testing.

Facebook Credits and Foreign currency

I am developing an application that uses FB Credits as a currency, however, my clients are going to be paying in their local currency (ILS, israeli sheqel).
I know the rate for 1 credit is 10 cents, however, the price in ILS seems to be changing according to changes in the exchange-rates of USD-ILS.
Is there a way to query Facebook Server to know the prices users are going to be charged in their local money? Like a way to query the pricelist. Many new users don't understand the concept of credits and i'd like to show them what they're about to pay in local money.
The Facebook Credits API doesn't have exchange rate information available. You could request this feature on their developer group. You're best bet would be to pull down an exchange rate feed (there are tons available if you search) and display that with a warning that it is just an estimated rate and that it is dependent on the actual exchange rate Facebook uses.
xe.com is a great feed , you can also pull data from yahoo or google finance
As stated by OffBySome, Facebook do not have exchange rate information available. Thinking about this, I can see why they don't have this as they do not want you to display the local currency price for items. Although at the moment Facebook Credits are relatively new, and there is a lot of confusion for end users, eventually when it becomes widespread there won't be these issues.
I would suggest for now (as that is what I have done - here one Facebook Credit is currently ~7p) that you just hard code in your app the price of 1 Facebook Credit in your local currency, and if required display this. I think one of the reasons why Facebook don't support this is that they didn't envisage apps using Credits to be restricted to one territory, however in reality not everything is a game to be used worldwide. :)
Just to sum this question up, I tried two methods. One was to pull the rate every 10 minutes from openexchange using this python function:
def update_ils_rate():
print "Updating ILS/USD exchange rate"
url = 'http://openexchangerates.org/latest.json'
response = requests.request('get', url)
content = response.content
data = loads(content)
return data['rates']['ILS']
However it seems that facebook credits calculates ILS(israeli sheqel) rate according to a different rate (calculations were off by a little). So we have decided to pull xml data from israel's central bank, using this function:
import requests, BeautifulSoup
def get_ils_rate():
response = requests.request('get', 'http://www.bankisrael.gov.il/currency.xml')
content = response.content
soup = BeautifulSoup(content)
currencies = soup.findAll('currency')
for c in currencies:
if c.currencycode.contents[0]=='USD':
return float(c.rate.contents[0])