How to send a custom context along with a submit_form message to the collector

Hi guys,

We have a web form in which there are several inputs. Three of them are day, month and year. Using the Snowplow gtm tag, we can collect the form element values when a customer submits the form. However, we also need the concatenation of three piece of data as a date. I have created a schema and a function to generate a new entity (context) like the below one:
“schema”: “iglu:com.your_company/form_submit/jsonschema/1-0-0”,
“data”: {
“concatenatedDate”: “1980-02-01”
But I couldn’t find a way to send this along with the submit_form message. Does anybody know what should I do?

The docs at Forms | Snowplow Documentation should be helpful, you have to add your function as a context generator when you call enableFormTracking.

So something like:

snowplow('enableFormTracking', {context: [function(form, fields) {
  if (arguments.length !== 2) return []; // not form_submit
  var concatenatedDate = "1980-02-01" // FIXME: do the date concatenation, you can use `form` to verify the correct form and `fields` to access the submission data
  return [{
    "schema": "iglu:com.your_company/form_submit/jsonschema/1-0-0",
    "data": {
      "concatenatedDate": concatenatedDate

If you didn’t want to use a dedicated entity just for this, you could also use transform functions to just populate one of the fields with the entire date value and use that for your analysis.