Campaign Report for a particular date can be easily downloaded programmatically by a REST API. This feature only provides campaign data for a single date at a time. For downloading data spanning across many days please refer here.
In the settings section of Dashboard, you can find Reports Settings.
- Enable the campaign reports.
- You can select the report to be sent via email or to be downloaded through REST API.
- You can also select the time at which Report should be generated or emailed.
API call is a GET request. Url for the API is given below -
- Replace [YOUR-API-ID-HERE] with the API-ID found under "APP Settings" of Moengage dashboard
- Filename should be of format YYYYMMDD.zip
- Generating the signature is explained below.
For Example, the following link will download the Campaign report of 2nd March 2016.
To verify the authenticity of the caller and validity of the request, we require a unique signature which is needed to be passed as a GET parameter. The signature is a combination of API-ID, FILENAME, and SECRET-KEY ( SECRET-KEY is provided in "APP Settings" of Moengage dashboard along with the API-ID ).
# SAMPLE IMPLEMENTATION IN PYTHON from hashlib import sha256 Api_ID = "YOUR-API-ID" FILENAME = "20160302.zip" SECRET_KEY = "YOUR-SECRET-KEY" Signature_Key = Api_ID + "|" + FILENAME + "|" + SECRET_KEY # Now Signature is hexdigest of sha256 of Signature_Key Signature = sha256(Signature_Key).hexdigest() # Generated Signature is - 2aca4dcb53a2ed026a60173b67cebb1f2875a47ac5fe06ca5aa478b93606b532
Sample API will look like this -
Response of the API call will automatically download the file for you, in case of failure you will see a JSON Response explaining the reason for failure.
You can test the API with a simple wget -
wget -O test.zip https://api.moengage.com/dailyCampaignReportDump/MAZW5N1IMMSH5H67C3T9KBHA/20160914.zip?Signature=838fe32cf4882860b0109ed371b1bf380ad640292b8178e9af129706ecfd24fe
After you enable the report settings in the dashboard, our system generates the daily report according to the schedule. Previous days campaign reports are not calculated. Please put a buffer time from the scheduled time, to pull the reports via API. There is no expiry for the reports generated.