Script manager

Overview

When building complex web sites, you often need to use third-party JavaScript code to integrate services, such as customer analytics. You integrate services such as Google Tag Manager (GTM) or Adobe Experience Platform, which enable you to quickly and easily update measurement or other code fragments on your sites without touching the content. They can be a valuable marketing tool, in addition to Sitefinity Insight.

In this article, you learn how to integrate external scripts, such as GTM on your Sitefinity CMS sites.

NOTE: When you change the script configuration, whether adding, editing, or deleting a script, Sitefinity CMS invalidates the output page cache for all affected sites. This can reduce the performance until the cache is rebuilt. For more information, see Output cache.

Add a new script to Sitefinity CMS

To add a new script, perform the following:

  1. In Sitefinity CMS backend, navigate to Administration » Settings » Script manager.
    The Script manager screen opens.
  2. If there are existing scripts, click Plus (Add).
    Otherwise, fill out the required fields.
  3. In Name, enter the name of the entry.
    You use this name to distinguish the script among all other entries in the list.
    For example, enter Google Tag Manager
  4. In Used in sites, select the sites where the script will be served.
    If you want to serve the script on specific sites, click Selected and in the Selected sites column, add the sites you want.
    Otherwise, click All to let Sitefinity CMS serve the script on all sites.
  5. In Scripts, click Edit (Edit).
    The Scripts page opens.
  6. Add the scripts, as instructed by the third-party provider. You can add as many scripts as you need.
    1. To configure Sitefinity CMS to add the script inside the <head> tag of every page, enter them in the Script in <head> tag field. The scripts are added to the end of the <head> tag.
    2. To configure Sitefinity CMS to add the script into the <body> tag of every page, enter them in the Script in <body> tag field. The scripts will be added to the beginning of the <body> tag.

      NOTE: You need to enter a fully formed HTML including the <script></script> tags.

  7. When finished, click Done » Save changes.

Edit and delete scripts

To edit or delete a script inside an existing configuration, perform the following:

  1. In Sitefinity CMS backend, navigate to Administration » Settings » Script manager.
    The Script manager screen opens.
  2. To edit scripts, click Edit (Edit).
    The Scripts page opens, where you can edit the scripts code.
  3. To delete an entry in the script manager, click its Remove (Remove) icon.
  4. Click Save changes.

Configure Script manager on particular pages

By default, the scripts configured in the Script manager are active on every page in your web site. You can selectively disable them for a particular page. This is useful, for example, if some pages contain sensitive data.

To configure whether the Script manager is active on a particular page, perform the following:

  1. In the Sitefinity CMS backend, navigate to Pages
  2. Click the Actions context menu of the page you want to manage, then select Title & properties.
  3. Check or uncheck Enable script manager.
  4. Save your changes.

Configure Sitefinity CMS security to enable requests to third-party web resources

The third-party scripts you use usually make requests to external web domains. By default, Sitefinity CMS security blocks such requests. For the integration to work properly, you need to allow these domains. Perform the following:

  1. In Sitefinity CMS backend, navigate to Administration » Settings » Web Security.
    The Web security page opens.
  2. In Trusted sources, click Edit.
    The Trusted sources dialog opens.
  3. In Scripts, enter the domains you want to allow, one domain per line.
    For example, enter *.example.com
  4. Click Done.

NOTE: Google Tag Manager is automatically enabled as a trusted source. However, if you are updating an existing Sitefinity deployment, you need to manually add its domains as described above.

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Get started with Integration Hub | Sitefinity Cloud | Sitefinity SaaS

This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.

Web Security for Sitefinity Administrators

This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?