Search the Omeda Knowledge Base

< All Topics
Print

Metering – Authorize Function Implementation

The Metering Authorize functions can be used to allow your site visitors to bypass a Meter once they’ve completed a form. With this method an “authorized” flag will be associated to the visitor’s cookie via a Javascript function that must be placed on the last page of the form. Unlike the product based implementation, the visitor’s product membership data will not be used to determine whether they will no longer be Metered. This allows for added flexibility when using an Omeda Form Builder form because forms built around behaviors or other non-product attributes can now be used within Meters. The authorize function can also be used on third party forms where Olytics is implemented.

It is important to note that the Authorize flag will expire for each visitor per the setting configured in the “Configuration” tab of the Meter labelled, “An authorized Visitor must re-authorize after”.

Authorize Function for Iframed or Embedded Form Builder Forms

If the form for the Meter is iframed within a Meter Message, the below function should be used, where meter-identifier represents the Meter Id that displays within the configuration tab.

olytics.authorizeWithIframe('meter-identifier')

When this function is fired the following will occur:

  1. The visitor will be authorized to bypass the meter
  2. Returns the visitor’s encrypted customer id to the parent site and closes the Meter Message.

When this function is used a close-confirm function should not be used on the form and the form should be set to Process Immediately.

For ease of use, we’ve provided an example of the full script that can be inserted into the head of the last page of the Form Builder form. Again, please note that the ‘meter-identifier’ must be replaced in the below script with the correct identifier for the meter.

// this UID is different for each meter:
var olyEncMeterId = 'meter-identifier';

if( document.readyState !== 'loading' ) {

    if(document.getElementById("olyticsImport")) {
        window.olytics.authorizeWithIframe(olyEncMeterId);
    } else {
        document.querySelector("#olyticsImport").addEventListener('load',function(){
        	window.olytics.authorizeWithIframe(olyEncMeterId);
        });
    }

} else {

    window.onload = function() {

        if(document.getElementById("olyticsImport")) {
        	window.olytics.authorizeWithIframe(olyEncMeterId);
        } else {
            document.getElementById("olyticsImport").onload = function(){
            	window.olytics.authorizeWithIframe(olyEncMeterId);
            };
        }   
 
    };
}

Authorize Function for Linked Form Builder Forms

If the form for the Meter is linked from a Meter Message, the below function should be used, where meter-identifier represents the Meter Id that displays within the configuration tab and redirectUrl represents the url the visitor should be returned to after the form is submitted. The visitor’s encrypted customer id (oly_enc_id) should be appended to the redirectUrl.

olytics.authorizeAndRedirect('meter-identifier', 'redirectUrl');

When this function is fired the following will occur:

  1. The visitor will be authorized to bypass the meter
  2. The visitor is directed to the url stored in the redirectUrl variable

For ease of use, we’ve provided an example of the full script that can be inserted into the head or header of the last page of the Form Builder form. Again, please note that the ‘meter-identifier’ and ‘redirectUrl’ must be replaced in the below script with the correct identifier for the meter and the return url. The form must also be set to Process Immediately.

<script>

// this UID is different for each meter:
var olyEncMeterId = 'meter-identifier';

if( document.readyState !== 'loading' ) {

    if(document.getElementById("olyticsImport")) {
        window.olytics.authorizeAndRedirect(olyEncMeterId, 'redirectUrl');
    } else {
        document.querySelector("#olyticsImport").addEventListener('load',function(){
        	window.olytics.authorizeAndRedirect(olyEncMeterId , 'redirectUrl');
        });
    }

} else {

    window.onload = function() {

        if(document.getElementById("olyticsImport")) {
        	window.olytics.authorizeAndRedirect(olyEncMeterId, 'redirectUrl');
        } else {
            document.getElementById("olyticsImport").onload = function(){
            	window.olytics.authorizeAndRedirect(olyEncMeterId, 'redirectUrl');
            };
        }   
 
    };
}
</script>

When using this function, you may want to populate the redirectUrl using merge variables. To do so the following script should be placed within an Export URL element with the type ‘Other’.

<script>

// this UID is different for each meter:
var olyEncMeterId = 'meter-identifier';

if( document.readyState !== 'loading' ) {

    if(document.getElementById("olyticsImport")) {
        window.olytics.authorizeAndRedirect(olyEncMeterId, 'redirectUrlMergeVariable?oly_enc_id=%%0.2.110%%');
    } else {
        document.querySelector("#olyticsImport").addEventListener('load',function(){
        	window.olytics.authorizeAndRedirect(olyEncMeterId , 'redirectUrlMergeVariable?oly_enc_id=%%0.2.110%%');
        });
    }

} else {

    window.onload = function() {

        if(document.getElementById("olyticsImport")) {
        	window.olytics.authorizeAndRedirect(olyEncMeterId, 'redirectUrlMergeVariable?oly_enc_id=%%0.2.110%%');
        } else {
            document.getElementById("olyticsImport").onload = function(){
            	window.olytics.authorizeAndRedirect(olyEncMeterId, 'redirectUrlMergeVariable?oly_enc_id=%%0.2.110%%');
            };
        }   
 
    };
}
</script>

Authorize Function for Third-Party Forms

If the form for the Meter is hosted by a third party, the below function should be used, where meter-identifier represents the Meter Id that displays within the configuration tab.

olytics.authorize('meter-identifier')

The third party form site must have Olytics implemented and the visitor’s anonymous or encrypted id must be passed to the metered site.

Table of Contents
Scroll to Top