Expand my Community achievements bar.

Join us at Adobe Summit 2024 for the Coffee Break Q&A Live series, a unique opportunity to network with and learn from expert users, the Adobe product team, and Adobe partners in a small group, 30 minute AMA conversations.
SOLVED

[Adobe Launch] Purchase Event via dataLayer

Avatar

Level 4

I need to pass the purchase details of a transaction in order to capture revenue/product level information.

If my digitalData / dataLayer contains these two bits of info, what should my rule be in Adobe Launch in order to pass this info to Adobe Analytics?

Thanks

--

digitalData.transaction.total =

{ purchaseID: "ABCAS",

basePrice: 100.00,

currency: "AED",

taxRate: 0.05,

priceWithTax: 105,

transactionTotal: 105 };

digitalData.transaction.item = {
basePrice: 100.00,
currency: "AED",
taxRate: 0.05,
priceWithTax: 105,
transactionTotal: 105,
category=smartphones,
product=Samsung smartphone,
quantity=1
};

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

In AA - Product String Builder - You should set product with only events and only eVar you want to set in the product string. Other events can be set within "AA - Set Variable" for the direct call rule you want to trigger on the purchase.

For currency Event - you need to make sure you set it correct and event2=%currency dataElement%

%currency dataElement% should return a numeric value, not a string.

View solution in original post

7 Replies

Avatar

Community Advisor

Hi,

Syntax:

  1. s.products="Category;ProductName;Qty;total_price [,Category2;ProductName2;Qty;total_price]"
  2. s.purchaseID="<%=getPurchaseID()%>"
  3. s.currencyCode="USD"
  4. s.events="purchase"

You will need to set transaction.total details in few currency events (event1, event2, event3, event4), purchaseId and currencyCode variables and transaction.item will go in s.products variable for each product (seperatrd by comma) as following E.g.

  1. s.products="smartphones";"Samsung smartphone";1;100.00,Running Essentials;Socks;10;29.50,"
  2. s.purchaseID="ABCAS"
  3. s.currencyCode="AED"
  4. s.events="purchase,event1=105,event2=0.05,event3=105,event4=105"

You can either use the custom code section to set it.

More Info:

Purchase Events

Avatar

Community Advisor

Dear Adil,

If these data layers are available, grab those values and build 'Data Elements'. Use the 'Data Elements' in the Page Load Rule to fire it based on your requirement.

If the Data Layers are available at the top, use 'Library Load'.

If the Data Layers are available on DOM, use 'DOM'.

Else use a 'Direct Call' rule and pass all the values to your function directly to trigger it along with your adobe Analytics Call.

I would go for 'Direct Call' Rule.

Thank you!

Arun

Avatar

Level 4

Hi Asheesh,

is there a specific syntax I need to follow in dataLayer to be able to read this in Adobe Launch?

Does the below code go in my custom code when I create a rule for transactions?

Also, in the below code - how will the dynamic values for event 1, event2 etc be populated here? Should it be "purchase,event1=%event1%, event2=%event2% where %event1%, %event2% are data elements?

Thanks,

  1. s.products="Category;ProductName;Qty;total_price [,Category2;ProductName2;Qty;total_price]"
  2. s.purchaseID="<%=getPurchaseID()%>"
  3. s.currencyCode="USD"
  4. s.events="purchase"

Avatar

Level 4

Hi Pratheep,

We already have a direct call to trigger the page load event. Does the custom code for purchase go within the existing Action configuration or do I need to create a new rule for Purchase events?

If it';s the existing direct call, then on a regular page load (NOT /thank-you page), what will the s.purchase events populate or they will not be utilized until this is available in the dataLayer?

Thanks.

Avatar

Community Advisor

is there a specific syntax I need to follow in dataLayer to be able to read this in Adobe Launch?

  • No, current datalayer structure looks good, you can read transaction.total details data in different data element, change its structure and use that to set it dynamically.

Also, in the below code - how will the dynamic values for event 1, event2 etc be populated here? Should it be "purchase,event1=%event1%, event2=%event2% where %event1%, %event2% are data elements?

  • Correct, either use custom code or launch product extension.

Does the below code go in my custom code when I create a rule for transactions?

  • Correct, alternatively you can use launch user interface or product extension

Note: To read transaction.item array use product extension by Adobe or any other launch extension.

Adobe Analytics Product String Launch Extension 

Avatar

Level 4

Hi,

Have you used Search Discovery's AA Product string builder?

If I want to use that extension,

which variables should I pass via AA - Set variables and AA - Product String builder?

I've asked in this thread as well Adobe Launch - steps to use AA Product String Builder Search Discovery  but will paste it here too:

My transaction event is supposed to fire on a direct call.

While using this AA string builder, which variables should I populate via AA "Set Variables" Vs "SDI string builder"

In my current workspace report, I can see that the Evars are populating for purchase category/product. However, the events [currency] are showing as 0 while ecommerce variables such as product/category are empty.

In my rule for Purchase event:

Adobe Analytics - Set variables has a few evars + events only

AA string builder has my root object as: %Transaction: Root Object% [where it is a JS var called digitalData.transaction]

Product collection path is set to: .transaction.item [because the object is available in digitalData.transaction.item]

Category is setup as .transaction.item.category as Collection Item Path

Quantity as 1 as Static Text

Unit price as .transaction.item.basePrice as Collection Item Path

Question: In the AA string builder, should I again set custom events if they are already set in the AA "Set variables" action?

I'm attaching a screenshot of the transaction object.

Thanks for reading and your help.Capture.JPG

Avatar

Correct answer by
Community Advisor

In AA - Product String Builder - You should set product with only events and only eVar you want to set in the product string. Other events can be set within "AA - Set Variable" for the direct call rule you want to trigger on the purchase.

For currency Event - you need to make sure you set it correct and event2=%currency dataElement%

%currency dataElement% should return a numeric value, not a string.