Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save guilhermemarconi/dad9101ac700fbcdbd221729d3d179e8 to your computer and use it in GitHub Desktop.
Save guilhermemarconi/dad9101ac700fbcdbd221729d3d179e8 to your computer and use it in GitHub Desktop.
//marketingData Example
//vtexjs.checkout.orderForm.marketingData
import { getCookie } from 'path/to/cookies.js'
utms = {
utmCampaign: (getCookie('IPS') && ~getCookie('IPS').indexOf('Campanha') ? getCookie('IPS').split('Campanha=')[1].split('&')[0] : ""),
utmMedium: (getCookie('IPS') && ~getCookie('IPS').indexOf('Midia') ? getCookie('IPS').split('Midia=')[1].split('&')[0] : ""),
utmSource: (getCookie('IPS') && ~getCookie('IPS').indexOf('Parceiro') ? getCookie('IPS').split('Parceiro=')[1].split('&')[0] : ""),
utmiCampaign: (getCookie('ISICI') && ~getCookie('ISICI').indexOf('InternalCampaign') ? getCookie('ISICI').split('InternalCampaign=')[1].split('&')[0] : ""),
utmiPart: (getCookie('ISICI') && ~getCookie('ISICI').indexOf('InternalPart') ? getCookie('ISICI').split('InternalPart=')[1].split('&')[0] : "")
}
//Execute after item was added to the cart.
vtexjs.checkout.sendAttachment('marketingData', utms);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment