Advertisement
Guest User

Untitled

a guest
May 26th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. var payload = {
  2. "apikey": API_KEY,
  3. "filters": {
  4. "sendtime_start": REPORT_START_DATE,
  5. "sendtime_end": REPORT_END_DATE
  6. }
  7. };
  8. Logger.log(payload );
  9.  
  10. var params = {
  11. "method": "POST", //what MC specifies
  12. "muteHttpExceptions": true,
  13. "payload": payload,
  14. "limit": 100
  15. };
  16. Logger.log(params);
  17.  
  18. var apiCall = function(endpoint) {
  19.  
  20. //issue with syntax here?
  21.  
  22. var apiResponse = UrlFetchApp.fetch(automationsList, params);
  23. var json = JSON.parse(apiResponse);
  24. Logger.log(apiResponse);
  25. return json;
  26. };
  27.  
  28. var automations = apiCall(automationsList);
  29. var automationsData = automations.data;
  30.  
  31. for (var i = 0; i < automationsData.length; i++) {
  32.  
  33.  
  34. // are these response parameters? are these specific values getting pulled from MC - these are the type of values i want?
  35. var a = automationsData[i];
  36. var aid = a.id; // identifies unique campaign *** does this have anything to do with the call function above - it used to be as cid b/c this was for campaigns before??
  37. var emails_sent = a.emails_sent;
  38. var recipients = a.recipients;
  39. var report_summary = a.report_summary;
  40. var settings = a.settings;
  41.  
  42. if (send_time) {
  43.  
  44. var r = apiCall(reports, cid); // why does this have cid? but the other one didn't??
  45. var emails_sent = r.emails_sent;
  46. var opens = r.opens;
  47. var unique_opens = r.unique_opens;
  48. var clicks = r.clicks;
  49. var unique_clicks = r.unique_clicks;
  50. var open_rate = (unique_opens / emails_sent).toFixed(4);
  51. var click_rate = (unique_clicks / emails_sent).toFixed(4);
  52.  
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement