Site-Wide Scripts
A site-wide script is a snippet of code that is to be included on every page of a site. The most popular site-wide script is Google Analytics. Follow the steps below to add a site-wide script to your site.
Important! You will need a Google user account to create a Google Analytics account. When creating a Google Analytics account, be sure to add more than one account-level administrator. Accounts should not be shared for security purposes. Any users with admin privileges should enable 2-factor authentication for secure login to their Google account.
Step 1: Create a Block
Blocks should be kept in a _blocks folder at the base level of a site. If your site does not have a _blocks folder, create one before proceeding (change folder settings to disable navigation and disable publishing).
- Select the _blocks folder in the asset tree, then click Add Content > Block
- For Block Type select Text, then click Choose at the upper right
- Enter a relevant Text Block Name (e.g., google-analytics, site-scripts); follow the requirements provided in the interface
- Scroll to Block Content and paste the script into the text editor; see important note regarding Google Analytics above
- Submit to save
Step 2: Edit the Setup Block and Choose the Script Block
- Select the Setup Block in the asset tree and then click Edit
- Scroll to the last setting for Additional Code; select Yes to enable
- Expand the Code section; two script locations are available, In Head (i.e., within the <head> HTML tag) and Before Closing Body (i.e., just before the </body> HTML tag); select the appropriate location based on script instructions
- Choose Block by browsing and selecting the block in the _blocks folder
- Submit to save
Step 3: Publish Full Site
You will never need to publish any blocks (script or Setup), however you will need to perform a full-site publish to add the script to the published version of every page. Moving forward, all new pages will automatically include the script when published.