Project Timezone

Mixpanel records all events assuming  Coordinated Universal Time (UTC)  at intake.

Before writing the event to Mixpanel data stores, Mixpanel converts the timezone to your project timezone. For example, if a project is set to Pacific time (UTC -8), Mixpanel subtracts eight hours from the timestamp before it is recorded in the database.

If you change your project timezone, it only changes the conversion applied to new events. Old events remain recorded in your project’s previous timezone because events are immutable–once they are recorded in Mixpanel, they cannot be changed.

Mixpanel sets project timezones by city or region.

If a city or region observes Daylight Savings Time, the ingestion offset adjusts appropriately.

If you do change your project timezone, you might see a brief gap or double-counting of events, depending on which timezone you switched from and to. However, the timezone self-corrects as soon as the hours of time difference have passed.

This article describes how to:

  • Change your timezone.
  • Understand why timezone affects your data.
  • Send date properties to Mixpanel.
  • Export data from Mixpanel.
  • Import data in Mixpanel.

Changing your Timezone

By default, Mixpanel sets your project timezone to Pacific time. Only project owners can change project settings.

To change the project’s timezone, select the Settings gear in the upper righthand corner of your Mixpanel project, and then select Project settings from the dropdown.

project-settings-1030.png

Change your timezone settings under the Management tab.

management-timezone-1030.png

 

Understanding How Timezones Affect Data

After you set your timezone correctly, any dates or times should be sent to Mixpanel in Coordinated Universal Time (UTC).

By default, Mixpanel’s integration libraries work with API ingestion endpoints to timestamp events for you in UTC.

Should you overwrite the default timestamp, import old data, or set a property that is in date format (e.g. Account Created Date), be sure to send the timestamp or date in UTC.

Upon receiving the timestamp or date in UTC time, Mixpanel will automatically convert the time to your project timezone before storing your data. This project timezone date or timestamp will be hardcoded in Mixpanel's backend and cannot be altered later.

Sending Date Properties to Mixpanel

As mentioned previously, you should send date properties to Mixpanel converted to UTC time. Date properties are one of the five data types Mixpanel accepts.

For this type of property, Mixpanel recommends an iso-formatted date string (YYYY-MM-DDTHH:mm:ss) to use in your Mixpanel reports.

Below are some code examples from Mixpanel's client-side libraries that allow you to send a property to Mixpanel with a correctly formatted UTC timestamp.

Javascript: new Date().toISOString()
mixpanel.track("Sign Up", {"Account Created Date": new
Date().toISOString()});
iOS: [NSDate date]
NSDate *today = [NSDate date];
[mixpanel.people set:@{@"Account Created Date": @today}];
Android: dateFormat.format(new Date()) 
final DateFormat dateFormat = new
SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.US); 
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
JSONObject props = new JSONObject(); 
try {
props.put("time-example", dateFormat.format(new Date())); 
} catch (Exception e) {
}
Mixpanel.track("Account Created Date", props);

Exporting Data from Mixpanel

When you’re exporting raw data from Mixpanel, your request requires the date parameters "from_date" and "to_date", which determine what date range of data to return.

The "from_date" and "to_date" values are interpreted by Mixpanel's raw export machines in relation to your project’s timezone. As a result, if you request a single day of data, you receive one full day in your project’s timezone, not one full day in UTC.

As mentioned earlier, timestamps on your events are hardcoded in your project’s timezone.

The "$time" property that’s returned from a raw export is a Unix timestamp, representing the number of seconds that have elapsed since 00:00:00 on January 1, 1970 in your project’s timezone, not UTC.

In the example below, if your project’s timezone is US/Pacific, the below parameters will return:

00:00:00 Aug. 1 to 11:59:59 Aug. 1 PDT, or 07:00:00 Aug. 1 – 06:59:59 Aug. 2 UTC. from_date = "2015-08-01" to_date = "2015-08-01"

Importing Data into Mixpanel

Imported data to Mixpanel should always be sent in UTC – timestamps on events and any date properties will need to be sent to Mixpanel in UTC to correctly display in your project.

If you’re working with exported Mixpanel data, the timestamps on events, and any date properties on events and people, will have been hardcoded into your project’s timezone. As a result, on an extract, transform, and load operation, a quick timestamp and date property offset is needed to reset your data back to UTC before importing it back into Mixpanel.

Is this article helpful?
10 out of 17 found this helpful

Comments

0 comments

Article is closed for comments.