How do I replace Campaigns [cmc_vid] token in non-URL attributes?
By default, the cmc.js script will replace tokens in the href="...", src="..." and value="..." attributes of HTML elements.
If you need to use a [cmc_vid] token in another type of attribute, you can add the attribute type to the existing list of attributes by including a special attrs property in a clickmagick_cmc object.
For example, if you had a special data-url="..." attribute, you could add that to the list by including this piece of code before you load the cmc.js script:
If you needed to add more than one attribute type, separate each one with a comma:
attrs: ['data-url', 'placeholder', ...],
If you already have an existing clickmagick_cmc object on the page because you’re tracking a Campaign click or conversion, add the attrs line anywhere in the existing object. Just be sure to include that final comma at the end of the line.
Adding the [cmc_vid] value to JavaScript code
In other cases, you might need to use the [cmc_vid] value in your JavaScript code.
In this scenario, if you don’t already have a clickmagick_cmc object on your page, add one with an empty vid field before you load the cmc.js file, like this: