Install bmetric
This guide outlines everything you need to know about bmetric's script and how to install it into your website.
Summary
To install bmetric you will need at least one script to run (our main-script). Depending on consent and the overall setup, you may need additional scripts to support these features.
The intended flow for consented tracking:
- Depending on visitor consent, set bellmetric_privacy_enabled = true/false (“true” if no consent, “false” if consent”).
- Run bmetric main-script.
- If consent changes without a new page load, refresh the script (described below). Script refresh may need to run on first pageview after consent has been given.
Note that:
- bmetric main-script must be loaded on all page views
- The window object value indicating consent type, must also be loaded on all subsequent page-views in the session and always before the main-script loads on the page view.
- Note though that a “light” setup is possible if you are running only calltracking
Installing bmetric
To install bmetric insert the following main-script on your website on all page views:
<script type="text/javascript"
src="//web.telemetric.dk/t/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXXX/bm.js"
async="async"></script>
Note that each script is unique. bmetric will provide you a unique script for your website.
Adding the script by itself will ensure that bmetric runs on your website for all visitors at all times.
If you are only running call-tracking and no other bmetric services (like engagements and/or forms), then you can skip the remainder of this guide; simply ensure that the above script runs on all pages and only after consent has been given; if no consent has been given, simply do not run the script.
In case you need to comply with cookie consent policies and are running other bmetric services other than calltracking, please follow the guide to section on consent mode and privacy mode.
Adding consent mode and privacy mode to bmetric
Taking consent into account will ensure you run tracking compliant with consent. If consent is not given, then the bmetric will either be blocked from running (or alternatively run the privacy version not applicable for call-tracking).
For consent support, please add the following scripts when relevant:
If you do not have consent to track the visitor (i.e. tracking consent denied), run the following script:
<script>
window._bellmetric_privacy_enabled = true;
</script>
If you have consent to track the visitor (i.e. tracking consent granted), run the following script:
<script>
window._bellmetric_privacy_enabled = false;
</script>
Ensure that the two above scripts are executed before the main-script provided in the previous section.
Updating consent without new page load
If consent changes without a new page load, refresh the script. Script refresh may need to run on first page view after consent given/denied.
<script>
// NOTE: The address bar URL (ie. window.location.href)
// MUST be updated already at this point
_bm = window._bellmetric || [];
_bm.push(['pageview', window.location.href]);
</script>
Execution order with web analytics platforms
Please always ensure that the bmetric script runs after any scripts related to web analytics, e.g. Google Analytics 4. Ensure that the bmetric script runs before 3rd party marketing scripts (like Meta or LinkedIn). Finally, ensure that the bmetric scripts runs before the bmetric privacy script (if applicable to your setup).
Execution order:
- Analytics scripts (Google Analytics 4, Adobe Analytics, etc.).
- bmetric script.
- 3rd party marketing scripts (Meta, LinkedIn, etc.).
Single page applications (SPA)
If your website is a Single page application then you will need to implement an additional script in order for our script to work correctly. Our script needs to be refreshed on each page load otherwise it can not track the user journey correctly.
In your tag manager you need to add this virtual pageview refresh after the bmetric script is loaded. This can be done via your existing tags after bmetric’s script has loaded.
<script>
// NOTE: The address bar URL (ie. window.location.href)
// MUST be updated already at this point
_bm = window._bellmetric || [];
_bm.push(['pageview', window.location.href]);
</script>
Content security policy
If you are using content security policies in your site, you need to whitelist our domains in order to allow our script to load all the resources they need from our servers.
More specifically our script requires that:
- Scripts must be allowed to load from the sources web.telemetric.dk and insight.bellmetric.net (script-src directive).
- Images and CSS must be allowed to load from the sources web.telemetric.dk and insight.bellmetric.net (image-src and style-src directives respectively).
- XMLHttpRequests must be allowed to load from the sources web.telemetric.dk and insight.bellmetric.net (connect-src directive).
Phone number formatting for call tracking
If you are using bmetric’s call tracking features please make sure that the phone number you want to track, is written in the HTML of your website as plain text. This way our script recognises a phone number and replaces it with a dynamic phone number. It also means that visitors from mobile phones will be able to press the number in their browser and call directly.
Script blocking
If bmetric’s script is blocked, our software will not function properly. Some ad-blockers and browsers may block our script or the tag manager used on the website. Script blocking can also be done intentionally when setting up bmetric with cookie consent; please see the relevant section for more information on this.
If you are using our embedded elements we recommend also installing our Fallback Elements to ensure optimal performance towards ad-blockers.
Testing and debugging
Checking if bmetric’s script is running
Once you’ve installed bmetric’s script and you want to check if it’s working, follow the steps below:
- In your browser navigate to the page you want bmetric’s script on.
- Open Development tools (right click and select “inspect” — in all browsers)
- Navigate to the console tab
- Enter the following command:
window._bellmetric
If it’s working, it will show something like this:
{init: f, ready: f, r: f, rc: f, readCookie: f, …}
If it’s not working it will return:
undefined
Checking if the privacy script works
If you need to check if Privacy script is running then follow the same procedure, running this command instead:
window._bellmetric_privacy_enabled
If the next line says true then the page is running in privacy-enabled mode. If it says false or undefined or null then the page is not running in privacy-enabled mode.