Home / Admin / Custom Separator
Duplicate Snippet

Embed Snippet on Your Site

Custom Separator

This code creates a custom separator smart tag for OptinMonster, which determines whether to use ? or & when adding query parameters to a redirect URL. It checks the current page URL and sets the correct separator when the campaign initializes.

Code Preview
js
function getSeparator() {
    return window.location.href.includes('?') ? '&' : '?';
}
document.addEventListener('om.Dtr.init', function (event) {
    const separator = getSeparator();
    event.detail.Dtr.setCustomVariable('separator', separator);
});

Comments

Add a Comment