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

✨ Source Amazon Ads: Added targeting grouping into SponsoredBrandsV3ReportStream. #48756

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ data:
connectorSubtype: api
connectorType: source
definitionId: c6b0a29e-1da9-4512-9002-7bfd0cba2246
dockerImageTag: 6.2.1
dockerImageTag: 6.3.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need also to add an entry in the docs changelog.

dockerRepository: airbyte/source-amazon-ads
documentationUrl: https://docs.airbyte.com/integrations/sources/amazon-ads
githubIssueLabel: source-amazon-ads
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,64 @@
"unitsSold14d": { "type": ["null", "string"] },
"adGroupName": { "type": ["null", "string"] },
"newToBrandUnitsSold14d": { "type": ["null", "string"] },
"campaignBudgetCurrencyCode": { "type": ["null", "string"] }
"campaignBudgetCurrencyCode": { "type": ["null", "string"] },
"addToCart": { "type": ["null", "integer"] },
"addToCartClicks": { "type": ["null", "integer"] },
"addToCartRate": { "type": ["null", "number"] },
"adGroupId": { "type": ["null", "integer"] },
"addToList": { "type": ["null", "integer"] },
"addToListFromClicks": { "type": ["null", "integer"] },
"qualifiedBorrows": { "type": ["null", "integer"] },
"qualifiedBorrowsFromClicks": { "type": ["null", "integer"] },
"royaltyQualifiedBorrows": { "type": ["null", "integer"] },
"royaltyQualifiedBorrowsFromClicks": { "type": ["null", "integer"] },
"brandedSearches": { "type": ["null", "integer"] },
"brandedSearchesClicks": { "type": ["null", "integer"] },
"campaignBudgetAmount": { "type": ["null", "number"] },
"campaignBudgetType": { "type": ["null", "string"] },
"campaignId": { "type": ["null", "integer"] },
"campaignStatus": { "type": ["null", "string"] },
"clicks": { "type": ["null", "integer"] },
"cost": { "type": ["null", "integer"] },
"costType": { "type": ["null", "string"] },
"detailPageViews": { "type": ["null", "integer"] },
"detailPageViewsClicks": { "type": ["null", "integer"] },
"eCPAddToCart": { "type": ["null", "number"] },
"endDate": { "type": ["null", "string"] },
"impressions": { "type": ["null", "integer"] },
"keywordBid": { "type": ["null", "number"] },
"keywordId": { "type": ["null", "integer"] },
"adKeywordStatus": { "type": ["null", "string"] },
"keywordText": { "type": ["null", "string"] },
"keywordType": { "type": ["null", "string"] },
"matchType": { "type": ["null", "string"] },
"newToBrandDetailPageViewRate": { "type": ["null", "number"] },
"newToBrandDetailPageViews": { "type": ["null", "integer"] },
"newToBrandDetailPageViewsClicks": { "type": ["null", "integer"] },
"newToBrandECPDetailPageView": { "type": ["null", "number"] },
"newToBrandPurchases": { "type": ["null", "integer"] },
"newToBrandPurchasesClicks": { "type": ["null", "integer"] },
"newToBrandPurchasesPercentage": { "type": ["null", "number"] },
"newToBrandPurchasesRate": { "type": ["null", "number"] },
"newToBrandSales": { "type": ["null", "integer"] },
"newToBrandSalesClicks": { "type": ["null", "integer"] },
"newToBrandSalesPercentage": { "type": ["null", "number"] },
"newToBrandUnitsSold": { "type": ["null", "integer"] },
"newToBrandUnitsSoldClicks": { "type": ["null", "integer"] },
"newToBrandUnitsSoldPercentage": { "type": ["null", "number"] },
"purchases": { "type": ["null", "integer"] },
"purchasesClicks": { "type": ["null", "integer"] },
"purchasesPromoted": { "type": ["null", "integer"] },
"sales": { "type": ["null", "integer"] },
"salesClicks": { "type": ["null", "integer"] },
"salesPromoted": { "type": ["null", "integer"] },
"startDate": { "type": ["null", "string"] },
"targetingExpression": { "type": ["null", "string"] },
"targetingId": { "type": ["null", "integer"] },
"targetingText": { "type": ["null", "string"] },
"targetingType": { "type": ["null", "string"] },
"topOfSearchImpressionShare": { "type": ["null", "number"] },
"unitsSold": { "type": ["null", "integer"] }
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,81 @@
"newToBrandSalesPercentage14d",
"newToBrandPurchasesPercentage14d",
"newToBrandUnitsSoldPercentage14d",
]
],
"targeting": [
"addToCart",
"addToCartClicks",
"addToCartRate",
"adGroupId",
"adGroupName",
"addToList",
"addToListFromClicks",
"qualifiedBorrows",
"qualifiedBorrowsFromClicks",
"royaltyQualifiedBorrows",
"royaltyQualifiedBorrowsFromClicks",
"brandedSearches",
"brandedSearchesClicks",
"campaignBudgetAmount",
"campaignBudgetCurrencyCode",
"campaignBudgetType",
"campaignId",
"campaignName",
"campaignStatus",
"clicks",
"cost",
"costType",
"detailPageViews",
"detailPageViewsClicks",
"eCPAddToCart",
"endDate",
"impressions",
"keywordBid",
"keywordId",
"adKeywordStatus",
"keywordText",
"keywordType",
"matchType",
"newToBrandDetailPageViewRate",
"newToBrandDetailPageViews",
"newToBrandDetailPageViewsClicks",
"newToBrandECPDetailPageView",
"newToBrandPurchases",
"newToBrandPurchasesClicks",
"newToBrandPurchasesPercentage",
"newToBrandPurchasesRate",
"newToBrandSales",
"newToBrandSalesClicks",
"newToBrandSalesPercentage",
"newToBrandUnitsSold",
"newToBrandUnitsSoldClicks",
"newToBrandUnitsSoldPercentage",
"purchases",
"purchasesClicks",
"purchasesPromoted",
"sales",
"salesClicks",
"salesPromoted",
"startDate",
"targetingExpression",
"targetingId",
"targetingText",
"targetingType",
"topOfSearchImpressionShare",
"unitsSold",
],
}

METRICS_TYPE_TO_ID_MAP_V3 = {
"purchasedAsin": "purchasedAsin",
"targeting": "keywordId",
}


class SponsoredBrandsV3ReportStream(SponsoredProductsReportStream):
"""
https://advertising.amazon.com/API/docs/en-us/guides/reporting/v3/report-types#purchased-product-reports
https://advertising.amazon.com/API/docs/en-us/guides/reporting/v3/report-types/purchased-product
https://advertising.amazon.com/API/docs/en-us/guides/reporting/v3/report-types/targeting
"""

API_VERSION = "reporting" # v3
Expand All @@ -49,6 +113,12 @@ def _get_init_report_body(self, report_date: str, record_type: str, profile):

reportTypeId = "sbPurchasedProduct"
group_by = ["purchasedAsin"]
filters = []

if record_type == "targeting":
reportTypeId = "sbTargeting"
group_by = ["targeting"]
filters = []

body = {
"name": f"{record_type} report {report_date}",
Expand All @@ -59,7 +129,7 @@ def _get_init_report_body(self, report_date: str, record_type: str, profile):
"groupBy": group_by,
"columns": metrics_list,
"reportTypeId": reportTypeId,
"filters": [],
"filters": filters,
"timeUnit": "SUMMARY",
"format": "GZIP_JSON",
},
Expand Down
Loading
Loading