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

Bug in the Models GetEmailCampaigns/GetEmailCampaign: Statistics not provided correctly #97

Open
Kaschmiri opened this issue Sep 23, 2024 · 0 comments

Comments

@Kaschmiri
Copy link

Kaschmiri commented Sep 23, 2024

I am trying to retrieve statistics on our Campaigns using the GetEmailCampaigns model, and I am trying to follow the example provided here: https://developers.brevo.com/reference/getemailcampaign

The API response seems to behave counterintuitively. According to the documentation, providing the parameter "statistics" is optional. I guess this means everything should be included, or nothing.
However, when excluded, the response will include entries for all the statistics, but the data will be 0 (see below).
Additionally, if you include one of the "statistics parameters", for example url = "https://api.brevo.com/v3/emailCampaigns/263?statistics=globalStats", those statistics will be correct.
However, the keys for "linkStats" (including the correct links), "statsByDevice", and "statsByBrowser" are still included, but show the value 0. Conversely, "statsByDomain" is empty.
That means that if I wanted to grab all available statistics on a campaign, I would have to loop through the 5 parameters globalStats, linkStats, statsByDomain, statsByDevice, and statsByBrowser, and reassemble the data.

pasted from the "Try it!" segment on the referenced page above, no parameter for "statistics" selected:

import requests

url = "https://api.brevo.com/v3/emailCampaigns/263"
headers = {
    "accept": "application/json",
    "api-key": "redacted"
}
response = requests.get(url, headers=headers)
print(response.text)

The response looks like this:

{
  "id": 263,
  "name": "redacted_campaign_name",
  "type": "classic",
  "status": "sent",
  "testSent": true,
  "header": "[DEFAULT_HEADER]",
  "footer": "EXISTS",
  "sender": {
    "name": "redacted",
    "id": 4,
    "email": "newsletter@redacted.com"
  },
  "replyTo": "newsletter@redacted.com",
  "toField": "",
  "previewText": "redacted_text",
  "tag": "",
  "inlineImageActivation": true,
  "mirrorActive": true,
  "recipients": {
    "lists": [],
    "exclusionLists": []
  },
  "statistics": {
    "globalStats": {
      "uniqueClicks": 0,
      "clickers": 0,
      "complaints": 0,
      "delivered": 0,
      "sent": 0,
      "softBounces": 0,
      "hardBounces": 0,
      "uniqueViews": 0,
      "unsubscriptions": 0,
      "viewed": 0,
      "trackableViews": 0,
      "trackableViewsRate": 0,
      "estimatedViews": 0
    },
    "campaignStats": [],
    "mirrorClick": 15,
    "remaining": 0,
    "linksStats": {
      "redacted_link": 0,
      "redacted_link", 0,
      "more_redacted_links", 0,
    },
    "statsByDomain": {},
    "statsByDevice": {
      "desktop": {
        "mac": {
          "clickers": 0,
          "uniqueClicks": 0,
          "viewed": 0,
          "uniqueViews": 0,
          "trackableViews": 0
        },
        "windows": {
          "clickers": 0,
          "uniqueClicks": 0,
          "viewed": 0,
          "uniqueViews": 0,
          "trackableViews": 0
        },
        "otherSystem": {
          "clickers": 0,
          "uniqueClicks": 0,
          "viewed": 0,
          "uniqueViews": 0,
          "trackableViews": 0
        }
      },
      "mobile": {
        "androidMobile": {
          "clickers": 0,
          "uniqueClicks": 0,
          "viewed": 0,
          "uniqueViews": 0,
          "trackableViews": 0
        },
        "iPhone": {
          "clickers": 0,
          "uniqueClicks": 0,
          "viewed": 0,
          "uniqueViews": 0,
          "trackableViews": 0
        }
      },
      "tablet": {
        "androidTablet": {
          "clickers": 0,
          "uniqueClicks": 0,
          "viewed": 0,
          "uniqueViews": 0,
          "trackableViews": 0
        },
        "appleIPad": {
          "clickers": 0,
          "uniqueClicks": 0,
          "viewed": 0,
          "uniqueViews": 0,
          "trackableViews": 0
        }
      }
    },
    "statsByBrowser": {
      "android": {
        "clickers": 0,
        "uniqueClicks": 0,
        "viewed": 0,
        "uniqueViews": 0,
        "trackableViews": 0
      },
      "chrome": {
        "clickers": 0,
        "uniqueClicks": 0,
        "viewed": 0,
        "uniqueViews": 0,
        "trackableViews": 0
      },
      "edge": {
        "clickers": 0,
        "uniqueClicks": 0,
        "viewed": 0,
        "uniqueViews": 0,
        "trackableViews": 0
      },
      "firefox": {
        "clickers": 0,
        "uniqueClicks": 0,
        "viewed": 0,
        "uniqueViews": 0,
        "trackableViews": 0
      },
      "internetExplorer": {
        "clickers": 0,
        "uniqueClicks": 0,
        "viewed": 0,
        "uniqueViews": 0,
        "trackableViews": 0
      },
      "opera": {
        "clickers": 0,
        "uniqueClicks": 0,
        "viewed": 0,
        "uniqueViews": 0,
        "trackableViews": 0
      },
      "safari": {
        "clickers": 0,
        "uniqueClicks": 0,
        "viewed": 0,
        "uniqueViews": 0,
        "trackableViews": 0
      },
      "electron": {
        "clickers": 0,
        "uniqueClicks": 0,
        "viewed": 0,
        "uniqueViews": 0,
        "trackableViews": 0
      },
      "mailChannelsScanner": {
        "clickers": 0,
        "uniqueClicks": 0,
        "viewed": 0,
        "uniqueViews": 0,
        "trackableViews": 0
      },
      "microsoft": {
        "clickers": 0,
        "uniqueClicks": 0,
        "viewed": 0,
        "uniqueViews": 0,
        "trackableViews": 0
      },
      "mozilla": {
        "clickers": 0,
        "uniqueClicks": 0,
        "viewed": 0,
        "uniqueViews": 0,
        "trackableViews": 0
      },
      "outlookExpress": {
        "clickers": 0,
        "uniqueClicks": 0,
        "viewed": 0,
        "uniqueViews": 0,
        "trackableViews": 0
      },
      "thunderbird": {
        "clickers": 0,
        "uniqueClicks": 0,
        "viewed": 0,
        "uniqueViews": 0,
        "trackableViews": 0
      },
      "yahooMailProxy": {
        "clickers": 0,
        "uniqueClicks": 0,
        "viewed": 0,
        "uniqueViews": 0,
        "trackableViews": 0
      },
      "unknown": {
        "clickers": 0,
        "uniqueClicks": 0,
        "viewed": 0,
        "uniqueViews": 0,
        "trackableViews": 0
      }
    }
  },
  "htmlContent": "redacted",
  "subject": "redacted",
  "scheduledAt": "redacted",
  "createdAt": "redacted",
  "modifiedAt":"redacted",
  "shareLink": "redacted",
  "sentDate": "redacted",
  "sendAtBestTime": false,
  "abTesting": false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant