Links

Get no of emails opened

Tags: #sendinblue #emails #campaign #opened #emailcampaigns #marketing #operations #snippet
Author: Minura Punchihewa​
This notebook get the number of emails opened

Input

Import libraries

import requests
import json
import naas

Setup Sendinblue

SENDINBLUE_API_KEY = naas.secret.get(name="SENDINBLUE_API_KEY") or "ENTER_YOUR_SENDINBLUE_API_KEY"

Variable

campaign_name = "Minura's Campaign"

Model

Send request to Sendinblue API

response = requests.get(
'https://api.sendinblue.com/v3/emailCampaigns',
headers={
'Accept': 'application/json',
'api-key': SENDINBLUE_API_KEY
}
)

Output

Get the campaign

campaign = next(item for item in json.loads(response.text)['campaigns'] if item["name"] == campaign_name)

Get the number of emails viewed (opened)

campaign['statistics']['globalStats']['viewed']