This task is for users with the following roles: OC Developer.
A third-party script is an externally sourced script that can be directly embedded into your site. It can be embedded into your site header or footer and apply to every page of your site, or it can be embedded into specific pages through the WYSIWYG toolbar.
When you receive a script from a third-party platform, the instructions will specify whether to add the script to the site header or footer of every page.
When they are intended to be added to every page on your site, the script is added to Device Variables.
The instructions will usually say:
- "The script should be included in your page header before the closing <head> tag on every page of your site."
- If this is the case, add the script to Device Variables > Custom Injection - Header
- "The script should be included in your page header before the </body> tag of your site."
- If this is the case, add the script to Device Variables > Custom Injection - Footer
Please note that adding all your scripts to your header can affect your site's performance, as the header always loads first. If you are concerned about this, then you can add scripts like Facebook Pixel and Google Tag Manager to your footer.
Some scripts we've seen frequently used are:
- Google Tag Manager
- Facebook Pixel
- Monsido
- Siteimprove
If your site is undergoing a refresh process, we may provide you with a code snippet to install a heat map. In this scenario, please go to More > Device Variables > Client Variables > Custom Injection - Header and paste the code in the Default value field.
This article will discuss 2 examples of third-party scripts, Facebook Pixel and Google Tag Manager that are added to the header of every page on your site. If you're looking for information about uploading embed codes to apply through your WYSIWYG on a page level, see Insert embed code.
Facebook Pixel and Google Tag Manager
When adding these scripts to your OpenCities site, you'll receive a script from Facebook Pixel or Google Tag Manager that needs to be inserted into the site's header. To do this:
- From the main menu, go to More > Device Variables
- Select Client Variables.
- Select Custom Injection - Header from the list of variables
-
Add the code snippet in the field Default value.
- Save when you’re done.
If you have multiple scripts to add to your site header, you just paste them one after the other in the Default Value field.
Please note that when using Facebook pixel there is a privacy concern about site visitors losing their anonymity. This loss of privacy would need to be covered in your cookies or privacy policy.
For more information about Facebook pixel, see the Facebook Business Help Center.
For more information about Google Tag Manager, see the Tag Manager Help center.
Adding Scripts to the Site Footer
The process for adding script to the footer is much the same as adding them to the header.
- From the main menu, go to More > Device Variables
- Select Client Variables.
-
Select Custom Injection - Footer from the list of variables
- Code snippets added to this variable are included just before the closing </body> tag of your site. You can use this variable to include any third-party JavaScript code in the site.
-
Add the code snippet in the field Default value.
- Save when you’re done.