For AI agents: a Markdown version of this page is at https://docs.snowplow.io/docs/event-studio/implement-tracking/snowtype-config.md. The index of all documentation pages is at https://docs.snowplow.io/llms.txt, and the index for this section is at https://docs.snowplow.io/docs/cdi/llms.txt.
Configure Snowtype sources and output options
Snowtype reads from the configuration file you created with snowtype init to determine which schemas to generate code for, and what language the code should be generated in. You can combine multiple source types in a single configuration.
We originally called tracking plans "data products". You'll still find the old term used in some existing APIs and CLI commands.
Configuration file structure
The configuration file is a JSON object with the following structure:
{
"organizationId": "a654321b-c111-33d3-e321-1f123456789g",
"tracker": "@snowplow/browser-tracker",
"language": "typescript",
"outpath": "./src/snowtype",
"dataProductIds": [
"a123456b-c222-11d1-e123-1f12345678dp"
],
"eventSpecificationIds": [
"a123456b-c222-11d1-e123-1f123456789g"
],
"dataStructures": ["iglu:com.myorg/custom_web_page/jsonschema/1-1-0"],
"igluCentralSchemas": ["iglu:com.snowplowanalytics.snowplow/web_page/jsonschema/1-0-0"],
"repositories": ["../data-structures"]
}
The organizationId, tracker, language, and outpath options will be pre-filled based on your answers to the snowtype init prompts.
Check out the configuration reference page for more details on the available options, including the supported trackers.
Add sources
Add sources to your configuration manually by editing the file, or with snowtype patch. The command will prompt you for the source type and ID, then update your configuration file:
npx snowtype patch
You can also pass in the source details directly:
# Add event specifications
npx snowtype patch --eventSpecificationIds <id1> <id2>
# Add data products
npx snowtype patch --dataProductIds <id1> <id2>
# Add data structures
npx snowtype patch --dataStructures iglu:com.example/my_entity/jsonschema/1-0-0
# Add Iglu Central schemas
npx snowtype patch --igluCentralSchemas iglu:com.snowplowanalytics.snowplow/web_page/jsonschema/1-0-0
# Add local schema repositories
npx snowtype patch --repositories ./local-schemas
You can disable automatic regeneration in your configuration file by setting regenerateOnPatch to false.
Tracking plans
A tracking plan groups related event specifications together. Adding a tracking plan to your configuration generates code for all of its event specifications at once.
To find the tracking plan ID, click Implement tracking on the tracking plan page in Console to get the command directly:

You can also copy the ID from the URL bar and add it to the dataProductIds array in your configuration file. The ID is the last part of the URL after /data-products/:

{
"dataProductIds": ["dp-id-1", "dp-id-2"]
}
Event specifications
You can add individual event specifications if you don't need the full tracking plan. Find the event specification ID on its page in Console. The ID is the last part of the URL after /event-specifications/:

Add the ID to the eventSpecificationIds array in your configuration file:
{
"eventSpecificationIds": ["es-id-1", "es-id-2"]
}
Data structures
To generate code for a specific data structure, you need its schema tracking URI. Find it on the data structure page in Console, under the Overview tab:

Add the URI to the dataStructures array in your configuration file:
{
"dataStructures": [
"iglu:com.example/my_event/jsonschema/1-0-0"
]
}
Iglu Central schemas
Iglu Central hosts schemas that you can use in your tracking. Find the schema tracking URI on the Iglu Central website under General Information:

Add the URI to the igluCentralSchemas array in your configuration file:
{
"igluCentralSchemas": [
"iglu:com.snowplowanalytics.snowplow/web_page/jsonschema/1-0-0"
]
}
Local data structure repositories
If you manage schemas locally using Snowplow CLI, you can point Snowtype at your local repository paths. Add them to the repositories array:
{
"repositories": ["./schemas"]
}
You can pass in the path to the data structures directly, or the Snowplow CLI directory root.
// This is fine
"repositories": ["./my-snowplow-tracking"]
// This also works
"repositories": ["./my-snowplow-tracking/data-structures"]
// This won't do anything
"repositories": ["./my-snowplow-tracking/data-products"]
Provide the path relative to the location of your configuration file.
Local tracking plans
Applies to Snowtype 0.20.0+Latest: 0.21.0If you manage tracking plans as code with Snowplow CLI, Snowtype can generate code from the tracking plan files in your repository. Add their paths to the localDataProducts array, and add the data structures their event specifications reference to repositories:
{
"tracker": "@snowplow/browser-tracker",
"language": "typescript",
"outpath": "./src/tracking",
"repositories": ["./data-structures"],
"localDataProducts": ["./data-products"],
"igluCentralSchemas": [],
"dataStructures": [],
"eventSpecificationIds": [],
"dataProductIds": []
}
Each path can be a directory or a single file, relative to the location of your configuration file. Snowtype reads every JSON and YAML file under a directory, uses the ones that declare resourceType: data-product, and follows their $ref links to source applications. snowtype patch has no option for localDataProducts, so edit the configuration file directly.
Snowtype reads the files in the format Snowplow CLI writes them, for example when you run snowplow-cli dp download.
For the fields Snowtype reads from each event specification, see local tracking plan fields.
Snowtype doesn't connect to Console, and doesn't need Console credentials, when the configuration lists localDataProducts and no dataStructures, eventSpecificationIds, or dataProductIds.
Run snowtype generate to write the code. When Snowtype generates only from your repository, it warns that it doesn't check schemas against the environments they're deployed to, and it doesn't create a .snowtype-lock.json file:
npx snowtype generate
✔: Valid configuration found
⚠ Warning: Generating from local definitions only. Schemas are not checked against the environments they are deployed to.
✔: Code generated, writing...
To combine local tracking plans with tracking plans from Console, also list the Console tracking plan IDs in dataProductIds. Snowtype then connects to Console and needs Console credentials. It generates code for the event specifications from both sources, and pins only the event specifications from Console in .snowtype-lock.json.
Each event specification must come from one place only. A tracking plan downloaded with Snowplow CLI keeps its Console IDs, so list it either in localDataProducts or in dataProductIds, not in both.
To confirm in CI that the committed code matches your tracking plan files, run snowtype check.
Troubleshooting
These errors stop snowtype generate and snowtype check for a configuration that lists localDataProducts. Each item gives the error message, then the fix:
Required API key credentials not detected. Run `snowtype login` to sign in, or refer to https://docs.snowplow.io/docs/collecting-data/code-generation/using-the-cli/#authenticating-with-the-console: the configuration connects to Console, and Snowtype found no login and no API key. Authenticate withsnowtype loginor a Console API key, or change the configuration so that it generates only from local tracking plans and doesn't need Console credentials.An event specification in a local data product does not declare its version: Sign up. Add a version to it in the data product file, matching the version the platform holds.: runsnowplow-cli dp validate --fix, which adds the missingversionto the tracking plan file.A schema referenced by a local event specification is not among the repositories or the Iglu Central schemas the configuration declares: iglu:com.example/missing/jsonschema/1-0-0, referenced by "Sign up": add the data structure to a path inrepositories, or add its URI toigluCentralSchemas.The same event specification is reached more than once, from Console or from more than one local data product: Sign up: list each tracking plan in one place only, either indataProductIdsor in one file underlocalDataProducts.