Mouseflow Help & Support

How do I whitelabel Mouseflow?

Follow

With Mouseflow, it's possible to whitelabel the URL used in your tracking code.

To do so, you'll need to setup a proxy script (see example below) which receives requests, fetches the appropriate tracking code from Mouseflow, and returns the contents to the end user.

It is important that this script is served from a server which is configured for HTTP and HTTPS (this requires an SSL certificate issued from a certificate authority). In addition, this method can impose added latency because the script reference results in two requests: one to the proxy script and one to the Mouseflow platform (from the proxy script). We recommend using caching and/or a content delivery network (CDN) to improve performance.

Once implemented, use of a proxy script will allow you to whitelabel the tracking code, as shown below:

[FIND]

//cdn.mouseflow.com/projects/xxx.js

[REPLACE]

//path.to.your.script/?id=xxx

Proxy Script (PHP)

<?php
/*

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
 
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
 
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

===============================
=========++IMPORTANT++=========
===============================

This script is intended to serve as a proxy for requests to obtain Mouseflow tracking code.

You must host the script on a server that supports HTTP and HTTPS and modify the script location(s) accordingly.

As an example:

[FIND]

//cdn.mouseflow.com/projects/xxx.js

[REPLACE]

//path.to.your.script/?id=xxx

This script will then proxy back the appropriate Mouseflow tracking code for use in the browser.

This method is preferred to self-hosting the Mouseflow tracking code, so that adjustments to settings and updates to Mouseflow will be available.

If you have any questions, please contact Mouseflow Support (https://mouseflow.com).

*/

header("Access-Control-Allow-Origin: *");

if (isset($_GET['id']) && !empty($_GET['id'])) {
	if (strlen($_GET['id']) == 36) {
		try {
			$id = $_GET['id'];
			$result = file_get_contents('https://cdn.mouseflow.com/projects/' . $id . '.js');
			header('Content-Type: application/javascript'); 
			echo $result;
		} catch (Exception $e) {
			print json_encode(array('STATUS' => 'REMOVE ERROR'));
		}
	} else {
		print json_encode(array('STATUS' => 'LENGTH INVALID'));
	}
} else {
	print json_encode(array('STATUS' => 'REQUEST INVALID'));
}

 

Tags: whitelabel path url script reference

Have more questions? Submit a request

Comments

Powered by Zendesk