Carnegie Mellon University


A service provided by the University CMS Team

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).

  1. Select the _blocks folder in the asset tree, then click Add Content > Block
  2. For Block Type select Text, then click Choose at the upper right
  3. Enter a relevant Text Block Name (e.g., google-analytics, site-scripts); follow the requirements provided in the interface
  4. Scroll to Block Content and paste the script into the text editor; see important note regarding Google Analytics above
  5. Submit to save

Step 2: Edit the Setup Block and Choose the Script Block

  1. Select the Setup Block in the asset tree and then click Edit
  2. Scroll to the last setting for Additional Code; select Yes to enable
  3. 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
  4. Choose Block by browsing and selecting the block in the _blocks folder
  5. 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 site-wide publish to add the script to the published version of every page. Moving forward, all new pages will automatically include the script when published.


If the existing block uses the same location where your script needs to go (i.e., either in the head or body HTML tag), you do not need to create another block; simply amend the existing block by pasting in the new script below any existing code (be careful not to modify any existing code).

If the existing block does not use the same location where your script needs to go, create a new block. In the setup, click the + sign near Additional Code to add a second block, then browse to choose the new block.

Note: Each site-wide script location (head and body HTML tags) should only contain one block each; additional scripts should be added to these blocks directly.

This will happen if you don't make the adjustment specified above for Google Analytics code. Newer code is missing the async="true" value which is required in the CMS. Find async in the code and include ="true" as in this example:

<script async="true" src=""></script>

After the adjustment, your site should function as normal.

Yes, this is possible.

  1. Complete Step 1 as instructed above
  2. For Step 2, instead of editing the Setup Block, edit the page where you want to add the script
  3. Click the Configure tab, then Choose Block for the appropriate location:
    1. Additional Optional - Head Tags - Add script to <head> HTML tag
    2. Additional Optional - Script Tags - Add script before closing </body> HTML tag
  4. Do not modify any other settings on page; submit to save
  5. Publish the page