Skip to content

Instantly share code, notes, and snippets.

@jtsternberg
Forked from thomasgriffin/setcustomvariable.js
Last active May 7, 2020 21:54
Show Gist options
  • Save jtsternberg/6045a7e0b7e3ecd72cea1fb4b8ca3d5f to your computer and use it in GitHub Desktop.
Save jtsternberg/6045a7e0b7e3ecd72cea1fb4b8ca3d5f to your computer and use it in GitHub Desktop.
OptinMonster Dynamic Text Replacement API - setCustomVariable
<script type="text/javascript">
document.addEventListener('om.Dtr.init', function(event) {
/**
* API method for setting a custom variable. Must be accessed via the Dtr object.
*
* @param string $key The custom variable key to set.
* @param string $value The custom variable value to set for the key.
* @return null
*/
event.detail.Dtr.setCustomVariable('foo', 'bar');
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment