Send your own metrics to Daily Metrics

You know that Daily Metrics' connectors can collect your metrics from different services like Google Analytics, Twitter, Mailchimp or others. That's nice, but there are many other metrics of your project which are not available on any of those services, but are calculated by your systems.

We know what you're thinking, you would also like to show those internal metrics in the Daily Metrics email... and of course we have you covered: the Daily Metrics API.

The Daily Metrics API is very simple. First grab your API key from the Project Settings page and then you only have to POST a request with your data and it will be available for you to show in the email template.

Sending the data is as easy as this example in Javascript:

const axios = require("axios");

const url = "https://app.thedailymetrics.com/api/metrics/";
const metrics = [
  {
    date: "2020-07-16",
    sales: 7500.25,
    users: {
      signups: 32,
      active: 101,
    },
    clients: {
      new: 32,
      churn: 10,
    },
  },
  {
    date: "2020-07-15",
    sales: 750.5,
    clients: {
      new: 10,
      churn: 5,
    },
  },
];
const apiKey = "{YOUR_API_KEY}";

axios
  .post(url, {
    apikey: apiKey,
    metrics: metrics,
  })
  .then(function (response) {
    // metrics successfully added
    console.log(response.data);
  })
  .catch(function (error) {
    // error adding metrics
    console.log("Error adding metrics!!");
    console.log(error);
  });

As you can see in the example code, the metrics argument is an array with an object for each day (if you're only sending metrics for one day, the array will only have one element). The object for each day must have a property called date with the date in "YYYY-MM-DD" format, while the rest of the properties of the object are free for you to use.

Once you have sent the data to Daily Metrics, you can access it from the email template using the m variable, as for example:

## Yesterday
Sales: <%= m[0].sales %>
User signups: <%= m[0].users.signups %>
Active users: <%= m[0].users.active %>

Interested? Try it out today and get your key metrics in a beautiful daily email!