Lóri Nóda
Lóri Nóda

Reputation: 750

Power BI - LinkedIn Ads connector

I would like to load LinkedIn Ads data into my Power BI report.

Are there any easy approach for accessing the data?

Thanks in advance!

Upvotes: 0

Views: 713

Answers (2)

Pushkin
Pushkin

Reputation: 1

there are few options to connect Linkedin ads to Power bi:

1- Downloading the csv files and importing to Power bi.

2- Creating an app in Developper.linkedin.Com, and getting the an API URL. Then in Power bi you press on Get data -> from web and then add your API URL in the box that appears.

3- This is probably the easiest option which is to use a third-party connector, but you will still need to create an app in Developper.linkedin.com, and use your client's id and client's secret key to be able to access your data.

Upvotes: 1

Lóri Nóda
Lóri Nóda

Reputation: 750

Turned out that you need to write or a custom connector by following the docs:

https://learn.microsoft.com/en-us/power-query/samples/trippin/readme

Or you need to write in M your custom code for accessing the API:

    let
    GetAccessToken = 
        let 
            TokenEndpointUrl = #"TokenEndpoint" &  "?client_id=" & #"AppID" & "&client_secret=" & #"AppSecret" & "&grant_type=client_credentials",
            TokenRequestResult = Json.Document(Web.Contents(TokenEndpointUrl)),
            AccessToken = TokenRequestResult[access_token]
        in 
            AccessToken,

    GetData = (Url)  => 
        let 
            FinalResult = if Url = ""
                then 
                    {}
                else 
                    let
                        Result = Json.Document(Web.Contents(Url,[
                            Query=[
                                date_preset="lifetime",
                                level="ad",
                                fields="impressions,spend,account_id,account_name,campaign_id,campaign_name,adset_id,adset_name,ad_id,ad_name",
                                time_increment="monthly"]
                        ])),
                        NextUrl = Record.FieldOrDefault(Result[paging],"next",""),
                        CombinedData = Result[data] & @GetData(NextUrl)
                    in  
                        CombinedData
        in 
            FinalResult,

    #"Data Endpoint" = #"DataEndpoint",
    AccessToken = GetAccessToken,
    #"Calls the functions and makes the result" = GetData(#"Data Endpoint" & "&acces_token=" & AccessToken)
in
    #"Calls the functions and makes the result"

Posting the answer here maybe it helps others too.

Upvotes: 0

Related Questions