The magnews code is the script that connects your website to magnews and allows the web property to work on the pages where it is installed.
When a visitor opens a page that contains the magnews code, the script communicates with the platform.
Based on the web property configuration, it can, for example, show on site messages and signup forms, record visitors' activities and send the collected data to magnews.
In practice:
- The web property defines the settings and features available for the website
- The magnews code allows the website and magnews to communicate
- Pages where the code is loaded can be tracked and show banners and popups
- Pages without the magnews code are not connected to magnews
This distinction is useful if you want to connect only some pages of your website to magnews, such as a signup area or a section dedicated to a specific service.
You can install the magnews code in two ways:
- Manually in the website code
- Through Google Tag Manager
Which method should you choose?
The choice depends on how your website is managed and how much autonomy you want to have over time.
- Manual installation is suitable if the website has few pages, if you have direct access to the code and if you want to add the magnews code only in specific places. It is a good choice for simple websites or for installations managed directly by a developer
- Google Tag Manager is more suitable if the website has many pages, if you already use it or if you want to avoid direct changes to the website code. It is the most flexible choice for marketing teams, because it lets you manage from GTM where to load the magnews code, where to exclude it and how to adapt the integration over time
Where to find the magnews code
The magnews code is always connected to a web property: before installing it, you need to have an existing web property or create one.
If you have already created a web property, open the property home and retrieve the code from the Add it to your site button, if the property is not active yet, or Code and check, if the property is already active.
If you do not have any web property yet, you can create one or start from the signup forms or on site messages page of your journey and click Connect your website.
When you connect the website from a signup form or from an on site message, for example during activation, magnews guides you through a three-step procedure. You will find the magnews code in the second step, right after entering the URL of the website to connect.
Install the code manually
Copy the magnews code of the web property you want to integrate and, if you have access to the website HTML code, paste it into the pages where you want to use the web property, right before the </head> tag.
If you do not manage the website directly, send the magnews code to the development team or to the person who manages the integration.
The magnews code works only on the pages where it is loaded: if you want to use the web property across the whole website, make sure the code is present on all pages.
When you add new pages, you will need to add it to their HTML too.
Verify manual installation
After installing the code manually, you can check whether magnews detects it correctly.
You can run the verification:
- From the second step of the guided procedure, when you connect the website during activation of the first on site message or signup form
- From the web property home, using Integrate into your website if the property is not active yet or Code and verification if the property is already active
After verification, magnews shows positive feedback if it finds the code on the website, or negative feedback if it cannot detect it.
Verification looks for the magnews code only on the main domain of the web property and only if the domain does not contain wildcards.
You can force the activation of the web property even if you do not run the verification or if the verification does not work.
Install the code with Google Tag Manager
You can use Google Tag Manager to load the magnews code on the website without directly changing its HTML code.
If you have never used Google Tag Manager, before installing the magnews code:
- Create an account and a container in Google Tag Manager
- Install the Google Tag Manager code on your website pages by following Google's official instructions
- Check that the GTM container has been published correctly
To configure Google Tag Manager from scratch, see the official Google Tag Manager documentation.
If you already use Google Tag Manager or if the Google Tag Manager container is already installed on the website pages, you can add the magnews code directly:
- Open Google Tag Manager and sign in to your account
- Create a new tag from the Tag menu
- Name the tag and select the Custom HTML tag type
- Copy the magnews code of the web property you want to integrate
- Paste the magnews code
- Set All Pages as the trigger
- Click Save
- To apply the changes to the website, click Submit
With this configuration, Google Tag Manager loads the magnews code on all pages where the GTM container is present.
If you want to use specific configurations, such as triggers other than All Pages or exclusions on specific pages, see the official Google Tag Manager documentation.
Examples
Show a popup only on one page
Imagine you manage the website of a multi-brand car dealership. In addition to selling cars, you offer after-sales services such as inspections and servicing.
To promote the opening of a new workshop, you want to show the Half-price servicing popup only on the Services page of the website.
To do this, install the magnews code on the pages where you want to use the web property:
- If you use Google Tag Manager, create a Custom HTML tag with the magnews code and use the All Pages trigger
- If you install the code manually, add it to all pages where you want to show on site messages or track visitors
Then, in magnews:
- Create the on site message
- Configure a display rule based on the URL, for example with the Current page rule and the condition URL contains services
- Activate the on site message
In this way:
- On the Home page and other pages, the magnews code is loaded, but the popup is not shown
- On the Services page, the magnews code is loaded and the popup is shown
You do not need to create a different web property for each popup. You can use the same web property and control the display of on site messages and signup forms through the rules you find in the settings.
Exclude a page from tracking
If you do not want to track visitors who open a specific page, you need to prevent the magnews code from loading on that page.
For example, you may choose not to load the magnews code on the Privacy and cookie policy page, because it is usually not useful for segmenting contacts, showing personalized messages or measuring conversions.
With manual installation, you simply do not add the magnews code to the page HTML. With Google Tag Manager, instead, you need to configure the tag so that it does not run on that URL.
Remember that on site message rules control when to show a message, but they do not prevent the magnews code from loading.
Check whether the web property is working
After installing the magnews code on your website, you can check whether the web property is receiving data in two ways:
Check the web property status
Open the web property home and check the integration status: if magnews receives events from the website, it means the code is communicating correctly with the platform. If no events are recorded, you will see a waiting status or an alert after 48 hours without activitySimulate the visit of a recognized contact
To check that visits are correctly associated with recognized contacts, send a communication to your email address, associated with a contact in a magnews database.
Add a link in the communication to a website page where the magnews code is installed.
Then open the communication, click the link and open the contact profile in magnews: in the Web tracking section, you should see the start of a new web session
If something does not work
If you have installed the magnews code but the web property does not receive events, the on site message is not displayed or the signup form does not appear on the website, see the page for troubleshooting common issues.