Skip to main content

Methods

tip

By default, MHCT is enabled and there is no need to call any method. All methods below are optional.

Once our javascript has loaded, you will have an mhct object of the name mhct available for use. It will contain the following methods:

enabled(value)

mhct.enabled(true); // true or false

If you want to enable or disable MHCT, this can be done using this method. Once disabled, MHCT will no longer track the user or change any numbers on the current page. The state of this does not persist across pages and persistence must be handled outside MHCT.

When MHCT is first enabled, it will begin to track the user and will change any phone numbers found on the website.

This method returns the value of the enabled() method after performing any update.

note

Only use this if you have set the enabled option to false.

tip

If you use this method, you must pass a boolean variable to this method, failure to do this will cause a console error.

caution

The state of this does not persist across pages and persistence must be handled outside MHCT.

enabled()

mhct.enabled(); // true or false

Use this method to check whether MHCT is enabled. This method returns true if it is enabled, or false if not.

changeMHNumbers()

mhct.changeMHNumbers();

Call this method if you want MHCT to change the numbers in the UI. It does not make any calls to our servers and just changes the UI.

Use this in conjunction with the mhAutoChange option

reload()

mhct.reload();

If you wish MHCT to parse the page and re-generate any numbers that are found, call this method.

This can be useful if the page contents are loaded via AJAX and you want to trigger a new page load within Mediahawk without actually reloading the page.

getVisitorMHRI()

mhct.getVisitorMHRI(); //a4WIy4NJnY

If you wish to retrieve the Visitor MHID to store or track for future use, this can be collected using this method. It returns a string.

getVisitMHRI()

mhct.getVisitMHRI(); //Bd7cPPWn49

If you wish to retrieve the Visit MHID to store or track for future use, this can be collected using this method. It returns a string.

trigger(dimensionIndex [, data])

mhct.trigger('dm1', {'value': 1.234, 'text': 'Additional info'});

If you wish to send data associated with Call-to-Action tracking, this can be done using this method.

Call-to-Action tracking can be of type sum or count.

dimensionIndex is the identifier associated with the dimension where data will be pushed. Possible values: dm1 to dm10.

data is a JavaScript object that holds additional information to be pushed, and has parameters value and text.

caution

If the dimension index specified is invalid or invalid data is provided, a console error will be caused.

note

The text parameter is optional.

tip

The value is required for sum type Call-to-Action.

tag(get_parameter, value)

mhct.tag('utm_campaign', 'email_campaign');

If you wish to manually trigger a tag to be associated with a visit in Mediahawk for a GET parameter that isn't in the URL, you can trigger additional parameters using this method.

caution

If the GET parameter hasn't been set up as a tag in Mediahawk, a console error will be thrown