Creating Custom Rules for Schema Publishing
Overview
When web page content doesn’t perfectly match schema vocabulary or property expectations, deploying accurate structured data can become a challenge. For example, your site might display “Mon” while schema.org expects “Monday.”
The Custom Rules feature in Milestone Schema Manager solves this by allowing you to create and apply JavaScript-based transformations so that schema properties reflect the correct format and values without needing to manually adjust every page.
Why You Need This Feature
Improved Schema Accuracy
Match your actual content to required schema formats using smart transformation rules.
Reduced Manual Tagging
Automate the mapping process instead of clicking and editing properties on each page.
Reusable Logic
Custom scripts can be applied across properties and groups of pages with similar patterns.
Better Automation, Less Effort
You save time, improve deployment speed, and ensure data integrity across templates.
Step-by-Step: How to Create Custom Schema Rules
Step 1: Navigate to the Schema Tagging Panel
Go to Milestone Schema Manager > Tag/View > Tag Schema from the left navigation panel.

Step 2: Choose the Schema to Edit
Click the Edit (pencil) icon next to the schema you want to apply the custom rule to.

Step 3: Add a Property to Modify
In the right-side schema toolbar, click the ‘+’ next to the schema type you’re editing (e.g., OpeningHoursSpecification, FAQ, etc.).
Step 4: Open Advanced Configuration for the Property
Find the property (e.g., dayOfWeek), click the three-dot menu, and select ‘Advanced Configuration’.
Example: Your site shows "Mon", "Tue", "Wed", but schema.org requires "Monday", "Tuesday", etc.
Step 5: Validate the XPATH
Check the XPATH of the element from which the data is being fetched. If the returned value is not in the expected schema format (e.g., "Mon" instead of "Monday"), proceed to customize it.
Step 6: Add a Filter and Choose ‘Custom Script’
Click ‘Add Filter’
From the dropdown menu, select ‘Custom Script’ to begin defining your transformation logic.
Step 7: Open and Edit the Script Section
Click into the script field. You’ll be writing your custom transformation logic using JavaScript (JS).
Step 8: Review the Input Value
At the top of the script editor, you’ll see the Input Value—this is the actual data captured from the page (e.g., "Mon").
Step 9: Write and Execute Your Script
Write a JavaScript function that converts or modifies the input.
Click ‘Execute’ to run your function.
Example transformation:
Step 10: Preview the Output
Once you execute the script, the Output Value will appear below. Confirm that it matches the schema format (e.g., "Monday").
Step 11: Apply the Script
Click ‘OK’ to save your script and close the editor.
Step 12: Save Your Custom Rule
Click ‘Save’ to apply the custom rule to the selected schema property. The Schema Manager will now automatically apply this logic when tagging content.
What Happens Next?
Once applied, the custom rule will immediately reflect in the live tagging section of Schema Manager, and you’ll see your schema properties updated accordingly.
If the input field is empty or not matched properly, the custom script will throw an error—so always validate before the final save.
Glossary of Terms
-
Custom Rule
A JavaScript-based logic modifies how content is interpreted and mapped to schema. -
XPATH
The path used to locate and extract specific content on a web page. -
Input Value
The content captured from the page before any transformation. -
Output Value
The transformed version of the input, suitable for schema deployment. -
Advanced Configuration
A power-user setting that allows deeper control over how schema properties are sourced and mapped.
Best Practices
- Always test your script before saving it to ensure accurate output.
- Use conditional logic for flexible transformations (e.g., mapping multiple variations).
- Keep your scripts reusable by writing them to handle more than one value where possible.
- Use this feature especially for:
- Day/time formatting
- Location abbreviations
- Product codes or pricing formats
- Translating frontend labels to schema vocabulary