Trigger Convert polling when URL hash changes

Issue Description

Convert experiments do not start when the URL has a hash.

For example:

A website homepage loads with the following URL:

https://domain.com/

After clicking on a link the page loads something like this:

http://domain.com/#features

But, if we setup an experiment with that URL, and the user, does not load that URL as the first visit to the site, the experiment will not trigger. 

This is a common issue of single page apps (SPAs).

Solution

Just add the following code to the Project Global JS section of your project.

convert.$(document).ready(function () {
convert.$(window).on('hashchange', function () {
_conv_q = _conv_q || [];
_conv_q.push(["run","true"]);
});
});

Note: Please test it with your SPA framework, as it might not detect hash changes in all frameworks.

Have more questions? Submit a request

Comments