How can I implement below code using custom code in Adobe Launch?
<script type='text/javascript'>
(function() {
var oid, total;
if (typeof digitalData !== 'undefined' && typeof digitalData.order !== 'undefined') {
oid = digitalData.order.id;
total = digitalData.order.total * .965;
} else {
oid = 'no order id';
total = 'no order total';
}
var img = document.createElement('img'),
cjactionid = '361222',
src="https://www.emjcd.com/u?TYPE=" + cjactionid + "&CID=88888&CURRENCY=USD&OID="+oid+"&AMOUNT="+total+"&METHOD=IMG",
eid = digitalData_cookie('cjevent'),
cjevent = (eid) ? "&CJEVENT=" + eid : "";
img.width = "20";
img.height = "1";
img.src=src + cjevent;
document.body.appendChild(img);
})();
</script>
?
Solved! Go to Solution.
Views
Replies
Total Likes
So here you have an IIFE so what you can do is take the code inside and put it in an action of a rule.
I can see that you are user a data layer layer from the variable digitalData.
There is 2 part to this code:
We will create data elements here to be able to reuse the data and also use some extension based on mapping table to set data based on specific rules. This way you can use same rule on different pages and just update data elements to return correct values.
Here is what I would do:
For #1
Create 2 data elements:
That's it for 1
For #2 we will create some additional data elements:
cjactionid = '361222',
eid = digitalData_cookie('cjevent'),
Ok now I would configure a rule to fire when you need, I would configure condition to make sure orderId and orderNumber do return a value and just no...
In the action paste this code:
var img = document.createElement('img'); img.src=`https://www.emjcd.com/u?TYPE=${_satellite.getVar('cjactionid')}&CID=88888&CURRENCY=USD&OID=${_satellite.getVar('orderId')}&AMOUNT=${_satellite.getVar('orderAmount')}&METHOD=IMG${(_satellite.getVar('eid') ? "&CJEVENT=" + _satellite.getVar('eid') : "")}`; img.width = "20"; img.height = "1"; document.body.appendChild(img);
One rule for your third party product to be fired based on values from data elements.
Hope this helps
So here you have an IIFE so what you can do is take the code inside and put it in an action of a rule.
I can see that you are user a data layer layer from the variable digitalData.
There is 2 part to this code:
We will create data elements here to be able to reuse the data and also use some extension based on mapping table to set data based on specific rules. This way you can use same rule on different pages and just update data elements to return correct values.
Here is what I would do:
For #1
Create 2 data elements:
That's it for 1
For #2 we will create some additional data elements:
cjactionid = '361222',
eid = digitalData_cookie('cjevent'),
Ok now I would configure a rule to fire when you need, I would configure condition to make sure orderId and orderNumber do return a value and just no...
In the action paste this code:
var img = document.createElement('img'); img.src=`https://www.emjcd.com/u?TYPE=${_satellite.getVar('cjactionid')}&CID=88888&CURRENCY=USD&OID=${_satellite.getVar('orderId')}&AMOUNT=${_satellite.getVar('orderAmount')}&METHOD=IMG${(_satellite.getVar('eid') ? "&CJEVENT=" + _satellite.getVar('eid') : "")}`; img.width = "20"; img.height = "1"; document.body.appendChild(img);
One rule for your third party product to be fired based on values from data elements.
Hope this helps
This is so very helpful.. Thank you for breaking it down in this way and being detailed. I really appreciate it
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies