When to use it
Writing objects one by one is slow for a large data layer. If the site already publishes one, copy it from a real page and import it. You then delete the entries you do not need and fill in descriptions.
Before you start
- Create the data layer first. See Document a Data Layer.
- Get the JSON. On a page of the site, open the browser console and run, for example,
JSON.stringify(digitalData)orJSON.stringify(dataLayer), then copy the output.
Import
- In Blueprint, click Data Layers.
- On the data layer's row, click the upload icon. The page opens as Import into followed by the data layer's title.
- Pick the Type of the objects you are importing.
- Paste the JSON into the JSON box.
- Click Submit.
You return to the data layer with the message "JSON was imported into data layer successfully."
What gets created
Each leaf value in the JSON becomes one object:
| Imported field | Comes from |
|---|---|
| Path | The key path, for example page.pageInfo.pageName |
| Example Value | The value found in your sample |
| Data Type | Worked out from the value: string, number, float (a number with a decimal point), boolean, and so on |
| Type | The Type you picked |
Arrays of plain values are imported as one object. Arrays of objects are walked into, and their positions are stored as [N], so ten products in a sample become one set of [N] paths, not ten.
Paths that already exist in the data layer are skipped, so re-importing a newer sample only adds the new keys.
Check it worked
Open the data layer. The Keys tab count has gone up, and the JSON tab shows the imported structure.
Troubleshooting
| Problem | Cause and fix |
|---|---|
| Nothing was imported | The box was empty or the text is not valid JSON. Paste the raw output of JSON.stringify(...), without surrounding quotes |
| "Please specify one or more valid data layer content" | No objects were found in the pasted JSON |
Paths starting with digitalData. show as W3C CEDDL | Blueprint always stores those as W3C CEDDL, without the prefix |