URL Parameters for Thank You Page Conversion Event

If your form submissions pass values via the URL to a thank-you page, you can implement the pre-built script below to capture these URL parameters and send them as a form conversion to Ruler Analytics. The script will automatically parse and submit the values exactly as they appear in the thank-you page URL. Note that this does not allow for customization of the captured values—how the parameters are passed depends on your form setup.

To ensure proper configuration of URL parameters in the thank-you page URL, we recommend consulting your form builder or provider for guidance.

Below is the JavaScript code that you can add to your thank-you pages directly to capture form submission data and URL parameters.

The below can also be implemented via Google Tag Manager as a 'Custom HTML' Script. Please ensure when implementing via GTM that the trigger is set to only fire on the Thank You page and not on all page views.

<script type="text/javascript">
var retryCount = 0;
function rulerConversion(){
    try{
        if(typeof(RulerAnalyticsVisitorId) === 'undefined') throw new Error('Ruler is not available.');
        var searchParams = window.location.search;
        var queryParams = searchParams.split('?')[1].split("&");
        var rulerAnalyticsPayload = {
            'action': 'convert'
        };
        queryParams.map(function(param){
            var keyValues = param.split('=');
            rulerAnalyticsPayload[keyValues[0]] = keyValues[1];
        });
        RulerAnalytics.trackConversionAsync(rulerAnalyticsPayload,"","", 200);
    }catch(error){
        if(retryCount <= 10){
            retryCount++;
            setTimeout(rulerConversion, 200);
        }
    }
}
window.addEventListener("load", rulerConversion);
</script>

🚧

Please be advised this is a Conversion Tracker script so should only be placed on your Thank you pages where you wish to signal a form conversion. Incorrect implementation of this script can lead to inflation of your conversion metrics.