Daily counting report to email via Google Script

This guide is to help you to receive daily email export of any Camlytics Service report via Google Script.

You would need a Google account in order to achieve that.

Follow the link https://script.google.com and click New Project as shown in the the snapshot below.

New project

Insert the following code into the code editor:

function myFunction() {
  var url = 'https://cloud.camlytics.com/feed/report/5a6c6cc272806490a973a80a7c42ca23/csv';//url your csv feed
  var email = 'here your email'; // email
  var reportName = 'My report'; // report base name

  var currentReportName = reportName + ' ' + (new Date()).toLocaleDateString() + ' ' + (new Date()).toLocaleTimeString() + '.csv';

  var csvBlob = UrlFetchApp
                         .fetch(url)
                         .getBlob()
                         .setName(currentReportName);

  MailApp.sendEmail({
        to: email,
        subject: 'Report',
        body: "Hello\r\nYour report is ready",
        attachments: [csvBlob]
    });
}

Next, you would need to update the code with your data, such as your email and csv feed URL for the report to export. The feed link can be copied as shown in the snapshot below:

csv feed

csv feed

After you update the code with your email and csv feed URL, save the code as shown in the snapshot below:

Save project

Next, we need to check how our script works, by clicking Run, as shown below:

Run project

If everything is correct, you will receive an email with csv export of the desired report.

To make this script to execute on schedule, go to the Triggers page (in the left menu).

Add trigger

On this page, click Add trigger. Next select the settings as shown below:

Trigger settings

Save trigger

Select the desired time and click Save.

If everything is corret, you will start receiving daily emails with the data from the report. See the video below for full guide.

Download Camlytics Service

Check out our YouTube channel which has plenty of real-life video analytics demos.

Our clients