CDP - Metering – Authorize Function Implementation

Knowledge Base Home

Search the Omeda Knowledge Base

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); }; } }; }

If you’d like the modal to wait three seconds after the form is submitted before closing, please use the script below as a guide.

// this UID is different for each meter: var olyEncMeterId = 'meter-identifier'; if( document.readyState !== 'loading' ) { if(document.getElementById("olyticsImport")) { setTimeout(function(){ window.olytics.authorizeWithIframe(olyEncMeterId); }, 3000); } else { document.querySelector("#olyticsImport").addEventListener('load',function(){ setTimeout(function(){ window.olytics.authorizeWithIframe(olyEncMeterId); }, 3000); }); } } else { window.onload = function() { if(document.getElementById("olyticsImport")) { setTimeout(function(){ window.olytics.authorizeWithIframe(olyEncMeterId); }, 3000); } else { document.getElementById("olyticsImport").onload = function(){ setTimeout(function(){ window.olytics.authorizeWithIframe(olyEncMeterId); }, 3000); }; } }; }

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.

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.

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’.

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.

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