although the notification seems to suggest that it...
# give-feedback
p
although the notification seems to suggest that it will start a fresh?
f
When you go to start the experiment again, it asks for a "Start Time" and anything before that date should be ignored by the queries.
p
hey @future-teacher-7046 hmmm that wasn't what i was experiencing - i can have another go
f
If it's still not working, can you paste in what you entered for "Start Time" and one of the SQL queries when you update results?
p
hey! sorry, i've been on vacation
am back now and this is still happening for me!
this is the default time it wants to start with
Copy code
function main() {
  // Experiment results - User decide boost UI2
  const metrics = [
    {
      "id": "met_3bwgdd13ks6bu7nn",
      "name": "created_plan"
      },
      {
        "id": "met_19g614ks32p0cy",
        "name": "appointment_booked"
      }
    ];
    return Events({from_date: "2021-09-21", to_date: "2021-09-21"})
    .filter(function(e) {
      if(e.name === "Experiment Viewed" && e.properties["experiment_id"] === "user-decide-boost-ui2") return true;
      // Metric - created_plan
      if(e.name === "created_plan") return true;
      // Metric - appointment_booked
      if(e.name === "appointment_booked") return true;
      return false;
    })
    // Metric value per user
    .groupByUser(function(state, events) {
      state = state || {
        inExperiment: false,
        start: null,
        variation: null,
        m0: null,
        m1: null, 
      };
      for(var i=0; i<events.length; i++) {
        const e = events[i];
        // User is put into the experiment
        if(!state.inExperiment && e.name === "Experiment Viewed" && e.properties["experiment_id"] === "user-decide-boost-ui2") {
          state.inExperiment = true;
          state.variation = e.properties["variation_id"];
          state.start = e.time;
          continue;
        }
        // Not in the experiment yet
        if(!state.inExperiment) {
          continue;
        }
        // Metric - created_plan
        if(e.name === "created_plan" && e.time - state.start < 259200000) {
          state.m0 = Math.min(1,(state.m0 || 0) + 1);
        }
        // Metric - appointment_booked
        if(e.name === "appointment_booked" && e.time - state.start < 259200000) {
          state.m1 = Math.min(1,(state.m1 || 0) + 1);
        }
      }
      return state;
    })
    // Remove users that are not in the experiment
    .filter(function(ev) {
      if(!ev.value.inExperiment) return false;
      if(ev.value.variation === null || ev.value.variation === undefined) return false;
      return true;
    })
    // One group per experiment variation with summary data
    .groupBy(["value.variation"], [
      // Total users in the group
      mixpanel.reducer.count(),
      // Metric - created_plan
      mixpanel.reducer.numeric_summary('value.m0'),
      // Metric - appointment_booked
      mixpanel.reducer.numeric_summary('value.m1'),
    ])
    // Convert to an object that's easier to work with
    .map(row => {
      const ret = {
        variation: row.key[0],
        dimension: '',
        users: row.value[0],
        metrics: [],
      };
      for(let i=1; i<row.value.length; i++) {
        ret.metrics.push({
          id: metrics[i-1].id,
          name: metrics[i-1].name,
          count: row.value[i].count,
          mean: row.value[i].avg,
          stddev: row.value[i].stddev,
        });
      }
      return ret;
    });
  }
ah! there is no time in the query, its just date
f
ok, I see. Mixpanel doesn't let you specify timestamp when getting the initial events. We can add a custom timestamp check in the first
filter
function though
p
ok brilliant, thx
i'll just schedule it to start from tomorrow