Follow the instructions below based on whether you're working with Editable Templates or Classic Templates.
Log in to your AEM instance and navigate to Tools > General > Templates.
Click Create and select Create Template.
Choose Editable Template and provide a name and description.
Similarly, create a Classic Template if required.
Define the layout and components directly in the template files.
For both Editable and Classic templates, extend the sling:resourceType property in your custom page component. This allows you to manage how scripts and other resources are included in your template.
1. Navigate to the head.html file in your custom page component folder.
2. Insert the JavaScript snippet directly into the file
This will ensure the script is included on every page that uses this template.
1. Create a Custom Component - Develop a custom component with a Rich Text Editor (RTE) field that allows administrators to input JavaScript snippets.
2. Add the Custom Component to the Structure Mode - Place the custom component in the Structure mode of the Editable Template so it is locked and cannot be modified on individual pages. Example code:
This setup ensures the JavaScript snippet is consistently applied across all pages derived from the template.
Once your templates are set up and the script is inserted:
For Editable Templates: Publish the template after confirming that the RTE field reflects the required JavaScript snippet.
For Classic Templates: Save and publish the head.html file to ensure the changes are applied to all relevant pages.
1. Go to the Nytro SEO dashboard.
2. From the left sidebar, select “Websites” ➡️ “Manage.”
4. Under Website Optimisation, click the “OPEN” button next to “Snippet is not installed.”
5. Click the “Verify installation” button (this may take a few seconds).
6. A notification will be displayed about the status of the verification.
1. Open your website in a browser.
2. Right-click on the page and select "Inspect" or press F12.
3. Go to the "Elements" tab.
4. Click the arrow down next to the <head>.
5. Check the JS snippet by using the search shortcut (Ctrl + F).
Utilize online tools like GTmetrix or Google Tag Assistant to verify the presence of the JS snippet, or use Chrome extensions.