linkedin-developers / linkedin-api-js-client

LinkedIn API JavaScript Client Library
Other
88 stars 20 forks source link

Linkedin Finder Method not returning specified fields #23

Closed adeel-outliant closed 1 year ago

adeel-outliant commented 1 year ago

I am using linkedin-api-js-client to get reporting data from linkedin.

I have tried multiple examples from here: https://learn.microsoft.com/en-us/linkedin/marketing/integrations/ads-reporting/ads-reporting?view=li-lms-2023-01&tabs=http%2Chttp-member-country-above0323%2Chttp-member-country-below0323%2Chttp-member-country-unversioned%2Chttp-memberregion-above0323%2Chttp-memberregion-below0323%2Chttp-memberregion-unversioned%2Chttp-above0323-membercounty%2Chttp-versioned-membercounty%2Chttp-unversion-membercounty#sample-request-1

But not able to get all fields except clicks and impressions .

Here is REQUEST CODE:

      const linkedInAdAnalytics = await this.linkedInRestliClient.finder({
        resourcePath: '/adAnalytics',
        finderName: 'statistics',
        queryParams: {
          pivots: ['CAMPAIGN'],
          timeGranularity: 'DAILY',
          campaigns: [
            'urn:li:sponsoredCampaign:<campaign-id>',
            'urn:li:sponsoredCampaign:<campaign-id>',
          ],
          dateRange: {
            start: {
              day: 1,
              month: 1,
              year: 2022,
            },
            end: {
              day: 4,
              month: 6,
              year: 2022,
            },
          },
        },
        versionString: '202301',
        accessToken,
      });

Here is RESPONSE:

{
  "paging": {
    "start": 0,
    "count": 10,
    "links": []
  },
  "elements": [
    {
      "clicks": 0,
      "impressions": 1,
      "pivotValues": [
        "urn:li:sponsoredCreative:<creative-id>"
      ],
      "dateRange": {
        "start": {
          "month": 2,
          "day": 8,
          "year": 2022
        },
        "end": {
          "month": 2,
          "day": 8,
          "year": 2022
        }
      }
    },
    {
      "clicks": 0,
      "impressions": 1,
      "pivotValues": [
        "urn:li:sponsoredCreative:<creative-id>"
      ],
      "dateRange": {
        "start": {
          "month": 2,
          "day": 2,
          "year": 2022
        },
        "end": {
          "month": 2,
          "day": 2,
          "year": 2022
        }
      }
    }
  ]
}

Need your help about how to get a response similar to mentioned below as per documentation

{ "elements": [ { "actionClicks": 0, "adUnitClicks": 0, "clicks": 177, "comments": 0, "companyPageClicks": 15, "conversionValueInLocalCurrency": "0.0", "costInLocalCurrency": "244.85000", "costInUsd": "244.85000", "dateRange": { "end": { "day": 20, "month": 3, "year": 2021 }, "start": { "day": 12, "month": 10, "year": 2020 } }, "externalWebsiteConversions": 0, "externalWebsitePostClickConversions": 0, "externalWebsitePostViewConversions": 0, "follows": 0, "impressions": 54494, "landingPageClicks": 67, "leadGenerationMailContactInfoShares": 0, "leadGenerationMailInterestedClicks": 0, "likes": 8, "oneClickLeadFormOpens": 0, "oneClickLeads": 0, "opens": 0, "otherEngagements": 1, "pivot": "CAMPAIGN", "pivotValues": [ "urn:li:sponsoredCampaign:1234567" ], "reactions": 0, "sends": 0, "shares": 0, "textUrlClicks": 0, "totalEngagements": 186, "viralClicks": 0, "viralComments": 0, "viralCommentLikes": 0, "viralCompanyPageClicks": 0, "viralExternalWebsiteConversions": 0, "viralExternalWebsitePostClickConversions": 0, "viralExternalWebsitePostViewConversions": 0, "viralFollows": 0, "viralImpressions": 86, "viralLandingPageClicks": 0, "viralLikes": 0, "viralOneClickLeadFormOpens": 0, "viralOneClickLeads": 0, "viralOtherEngagements": 0, "viralReactions": 0, "viralShares": 0, "viralTotalEngagements": 0 } ], "paging": { "count": 10, "links": [], "start": 0 } }