Last active
January 25, 2019 02:49
-
-
Save rgoytacaz/688131d05178614563f5e103f1b08ae6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//marketingData Example | |
//vtexjs.checkout.orderForm.marketingData | |
//Example 1: GET UTMS FROM COOKIES OR EMPTY | |
utms = { | |
utmCampaign: (Cookies.get('IPS').indexOf('Campanha')!= -1 ? Cookies.get('IPS').split('Campanha=')[1].split('&')[0] : "" ), | |
utmMedium: (Cookies.get('IPS').indexOf('Midia')!= -1 ? Cookies.get('IPS').split('Midia=')[1].split('&')[0] : "" ), | |
utmSource: (Cookies.get('IPS').indexOf('Parceiro')!= -1 ? Cookies.get('IPS').split('Parceiro=')[1].split('&')[0] : "" ), | |
utmiCampaign: (Cookies.get('ISICI').indexOf('InternalCampaign')!= -1 ? Cookies.get('ISICI').split('InternalCampaign=')[1].split('&')[0] : "" ), | |
utmiPart: (Cookies.get('ISICI').indexOf('InternalPart')!= -1 ? Cookies.get('ISICI').split('InternalPart=')[1].split('&')[0] : "" ) | |
} | |
//Example 2: GET UTMS FROM CURRENT ORDERFORM | |
//YOU CAN CHECKOUT VTEXJS.CHECKOUT.ORDERFORM.MARKETINGDATA | |
utms = { | |
utmCampaign: vtexjs.checkout.orderForm.marketingData.utmCampaign, | |
utmSource: vtexjs.checkout.orderForm.marketingData.utmSource | |
} | |
//EXAMPLE 3: SETTING YOUR OWN | |
utms = { | |
coupon: "MYCOUPON", | |
marketingTag: [], | |
utmCampaign: "", | |
utmMedium: "", | |
utmSource: "", | |
utmiCampaign: "", | |
utmiPart: "" | |
} | |
//EXAMPLE 4: EMPTY MARKETING DATA | |
utms = { | |
coupon: "", | |
marketingTag: [], | |
utmCampaign: "", | |
utmMedium: "", | |
utmSource: "", | |
utmiCampaign: "", | |
utmiPart: "" | |
} | |
//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