Skip to content

Web Tag Installation

The web tag is a small JavaScript snippet that allows you to track various events and send data to the service for analysis.

Installation

Add the following code snippet to the <head> section of your website's HTML:

html
<script>
window._almeta = window._almeta || { data: [['id', 'wt_1234567890abcd']], t: function t() { var _almeta$data; (_almeta$data = _almeta.data).push.apply(_almeta$data, [[arguments[0], arguments[1]]]); } };
</script>
<script async src="https://wt.almeta.cloud/wt.js"></script>

Replace 'wt_1234567890abcd' with your unique website tracking ID provided by the service.

Usage with Google Tag Manager

If you are using Google Tag Manager, you can add the web tag as a custom HTML tag:

  1. Go to the Tags section in Google Tag Manager.
  2. Click the New button to create a new tag.
  3. Select the Custom HTML tag type.
  4. Paste the web tag code into the HTML field.
  5. Add a Page View trigger to fire the tag on all website pages.
  6. Save the tag and publish the changes.

If you need to get consent from users before tracking events, you can use the Additional Consent Checks feature in Google Tag Manager. In that case, we recommend running the web tag script on page load, but not tracking actual events until you get a tracking consent from the user. The web tag does not send any data to the server until you track an event.

If you need a more flexible solution, you can add the ['require_consent', true] parameter to the web tag code:

html
<script>
window._almeta = window._almeta || { data: [['id', 'wt_1234567890abcd'], ['require_consent', true]], t: function t() { var _almeta$data; (_almeta$data = _almeta.data).push.apply(_almeta$data, [[arguments[0], arguments[1]]]); } };
</script>
<script async src="https://wt.almeta.cloud/wt.js"></script>

Note the ['require_consent', true] parameter. This will prevent the web tag from sending any data to the server until you run the following code (should be run after getting consent from the user):

javascript
_almeta.t('consent', true)

Subscribing to Web Tag Notifications

The web tag emits custom javascript events (notifications) that you can subscribe to in your code. For example, you can listen for the almeta_wt_response event to get the status of tracked browser events:

javascript
window.addEventListener('almeta_wt_response', yourCallbackFunction)

Here is an example of a callback function that logs the status of a tracked event:

javascript
window.addEventListener('almeta_wt_response', function (event) {
	if (event.detail.status == 'ok')
		console.log('Successfully tracked event', event)
	else
		console.error('Error tracking event', event)
})

Emitted Javascript Events

Event NameDescription
almeta_wt_responseEmitted when the web tag receives a response from the server.
almeta_ml_calculationEmitted when the server sends a prediction calculation result.
almeta_webml_calculationEmitted when a machine learning calculation is performed on the client side.