내 커뮤니티 업적 표시줄을 확대합니다.

Join us on September 25th for a must-attend webinar featuring Adobe Experience Maker winner Anish Raul. Discover how leading enterprises are adopting AI into their workflows securely, responsibly, and at scale.

Mark Solution

활동이 없어 이 대화는 잠겼습니다. 새 게시물을 작성해 주세요.

해결됨

Admitad affiliate tracking firing using custom code

Avatar

Level 4

I am trying to implement below code for Admitad Affiliate tracking on the confirmation page. And, I wanted to see how can I break the code down to data elements, so I do not have to put all in custom code rule.

 

 

<script src="https://www.artfut.com/static/tagtag.min.js?campaign_code=e0f12eb222" onerror='var self = this;window.ADMITAD=window.ADMITAD||{},ADMITAD.Helpers=ADMITAD.Helpers||{},ADMITAD.Helpers.generateDomains=function(){for(var e=new Date,n=Math.floor(new Date(2020,e.getMonth(),e.getDate()).setUTCHours(0,0,0,0)/1e3),t=parseInt(1e12*(Math.sin(n)+1)).toString(30),i=["de"],o=[],a=0;a<i.length;++a)o.push({domain:t+"."+i[a],name:t});return o},ADMITAD.Helpers.findTodaysDomain=function(e){function n(){var o=new XMLHttpRequest,a=i[t].domain,D="https://"+a+"/";o.open("HEAD",D,!0),o.onload=function(){setTimeout(e,0,i[t])},o.onerror=function(){++t<i.length?setTimeout(n,0):setTimeout(e,0,void 0)},o.send()}var t=0,i=ADMITAD.Helpers.generateDomains();n()},window.ADMITAD=window.ADMITAD||{},ADMITAD.Helpers.findTodaysDomain(function(e){if(window.ADMITAD.dynamic=e,window.ADMITAD.dynamic){var n=function(){return function(){return self.src?self:""}}(),t=n(),i=(/campaign_code=([^&]+)/.exec(t.src)||[])[1]||"";t.parentNode.removeChild(t);var o=document.getElementsByTagName("head")[0],a=document.createElement("script");a.src="https://www."+window.ADMITAD.dynamic.domain+"/static/"
+window.ADMITAD.dynamic.name.slice(1)+window.ADMITAD.dynamic.name.slice(0,1)+".min.js?campaign_code="+i,o.appendChild(a)}});'></script>



<script type="text/javascript">


ADMITAD = window.ADMITAD || {};
ADMITAD.Invoice = ADMITAD.Invoice || {};
if (!getSourceCookie(cookie_name)) {
  ADMITAD.Invoice.broker = 'na';
} else if (getSourceCookie(cookie_name) != deduplication_cookie_value) {
  ADMITAD.Invoice.broker = getSourceCookie(cookie_name);
} else {
  ADMITAD.Invoice.broker = 'adm';
}

ADMITAD.Invoice.category = '1';  // place to set the variable transactionAction


var orderedItem = [];

var positions = bt.order.items;      // place to set the variable transactionProducts

for (i = 0; i < positions.length; ++i) {
   orderedItem.push({
       Product: {
           productID: positions[i]['productid'],
           category: "1",
           price: positions[i]['price'],
           total: positions[i]['total'],
           priceCurrency: "USD",
                        },
       orderQuantity: positions[i]['quantity'],
       additionalType: "sale"
      
   });
}

ADMITAD.Invoice.referencesOrder = ADMITAD.Invoice.referencesOrder || [];
ADMITAD.Invoice.referencesOrder.push({
 orderNumber: bt.order.id,          // place to set the variable transactionId
 orderedItem: orderedItem
});
</script>

 

1 채택된 해결책 개

Avatar

정확한 답변 작성자:
Community Advisor

You don't.

Data elements are meant to pass data to your rules or to other data elements. They're not meant for running code like what you want.

So you should really put your entire code block into one big Custom Code action in a relevant rule, then replace "bt.order.id" and "bt.order.items" with your data elements.

원본 게시물의 솔루션 보기

4 답변 개

Avatar

Community Advisor

You need to provide the following to the code:

  • bt.order.id
  • bt.order.items

Do you already have these as data elements?

Avatar

Level 4

 

Yes those are already data elements.

 

How can I move below code to data elements

 

ADMITAD = window.ADMITAD || {};
ADMITAD.Invoice = ADMITAD.Invoice || {};
if (!getSourceCookie(cookie_name)) {
  ADMITAD.Invoice.broker = 'na';
} else if (getSourceCookie(cookie_name) != deduplication_cookie_value) {
  ADMITAD.Invoice.broker = getSourceCookie(cookie_name);
} else {
  ADMITAD.Invoice.broker = 'adm';
}

 

 

ADMITAD.Invoice.referencesOrder = ADMITAD.Invoice.referencesOrder || [];
ADMITAD.Invoice.referencesOrder.push({
 orderNumber: bt.order.id,          // place to set the variable transactionId
 orderedItem: orderedItem

Avatar

정확한 답변 작성자:
Community Advisor

You don't.

Data elements are meant to pass data to your rules or to other data elements. They're not meant for running code like what you want.

So you should really put your entire code block into one big Custom Code action in a relevant rule, then replace "bt.order.id" and "bt.order.items" with your data elements.

Avatar

Level 4

Thank you!! That is super helpful