# Get Analytics API data for Campaigns filtered by Source

**URL:** <https://community.hubspot.com/t/get-analytics-api-data-for-campaigns-filtered-by-source/56174>\
**Category:** APIs & Integrations\
**Created:** [May 4, 2022, 11:19am UTC](https://community.hubspot.com/t/get-analytics-api-data-for-campaigns-filtered-by-source/56174 "2022-05-04T11:19:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![PMunar](https://avatars.discourse-cdn.com/v4/letter/p/ac91a4/32.png) [@PMunar](https://community.hubspot.com/u/PMunar)\
**Post date:** [May 4, 2022, 11:19am UTC](https://community.hubspot.com/t/get-analytics-api-data-for-campaigns-filtered-by-source/56174/1 "2022-05-04T11:19:27Z")

</div>

Hi everyone!

I am interested in obtaining Analytics API data at campaign or utm\_campaign level filtered by Source.

I know that the endpoint for getting the information at utm\_campaign level could be something like:

[https://api.hubapi.com/analytics/v2/reports/utm-campaigns/total?hapikey=demo&start=20180101&end=20180301](https://api.hubapi.com/analytics/v2/reports/utm-campaigns/total?hapikey=demo&start=20180101&end=20180301)

and to obtain at Source level would be:

[https://api.hubapi.com/analytics/v2/reports/sources/total?hapikey=demo&start=20180101&end=20180301](https://api.hubapi.com/analytics/v2/reports/sources/total?hapikey=demo&start=20180101&end=20180301)

Is there a way in which I can obtain all utm\_campaign data for a specific Source?

Thanks a lot!

Pere

---

<div class="post-metadata">

**Author:** ![LMeert](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/lmeert/32/103847_2.png) [@LMeert](https://community.hubspot.com/u/LMeert)\
**Post date:** [May 4, 2022, 2:14pm UTC](https://community.hubspot.com/t/get-analytics-api-data-for-campaigns-filtered-by-source/56174/2 "2022-05-04T14:14:15Z")

</div>

Hi @PMunar ,

You can get all utm\_campaign data for a specific source indeed 🙂

If you [refer to this doc](https://legacydocs.hubspot.com/docs/methods/analytics/get-analytics-data-breakdowns) (which helped you get both urls above), you will see that you can use a parameter called d1 to dive a little bit deeper into the data that is returned to you.  
If you run this call on your instance (add your own hapikey), you will see that you get the data for the **email source only** as well as a breakdown by campaign :  
[https://api.hubapi.com/analytics/v2/reports/sources/total?d1=email?hapikey=demo](https://api.hubapi.com/analytics/v2/reports/sources/total?d1=email?hapikey=demo)  
Not all the sources will give you a breakdown by utm\_campaign, to know which ones do, it’s actually quite simple : the API mimics what you can explore in the web analytics report.  
Open Hubspot and go to Reports \> Analytics Tools \> Traffic Analytics.  
The report should already be by source, you can then scroll down to get to the table data and click on any source to dive into a specific source data.

If the table shows utm\_campaigns in the first column, that means the API will give you such a breakdown.

 ![LMeert_0-1651673730610.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/4/8/482d2f323da9df51887d3476b409862a76900cd0.png)

For example, here I clicked on “email marketing”.

If you want to know which values the d1 parameter can take, simply run this call :  
[https://api.hubapi.com/analytics/v2/reports/sources/total?hapikey=demo](https://api.hubapi.com/analytics/v2/reports/sources/total?hapikey=demo)

In the JSON response, look for the breakdowns list and locate each breakdown value (example below).

```lia-code-sample
 "breakdowns": [
 {
 "breakdown": "organic",
 "contactsPerPageview": 0.017413422030913714,
 "returningVisits": 3334,
 "rawViews": 5111,
 "contactToCustomerRate": 0.38202247191011235,
 "standardViews": 5111,
 "customersPerPageview": 0.006652318528663667,
 "sessionToContactRate": 0.02669466106778644,
 "pageviewsPerSession": 1.5329934013197362,
 "opportunities": 17,
 "bounceRate": 0.35602879424115175,
 "salesQualifiedLeads": 1,
 "marketingQualifiedLeads": 1,
 "visits": 3334,
 "pageviewsMinusExits": 5111,
 "leads": 3,
 "leadsPerView": 5.869692819409117E-4,
 "customers": 34,
 "evangelists": 23,
 "bounces": 1187,
 "time": 450162,
 "timePerSession": 135.02159568086384,
 "contacts": 89,
 "others": 10
 }
 ]

```

Hope this helps !  
If it does, please consider marking this answer as a solution 🙂
