Adobe Analytics event serialization & custom javascript coding for purchase event

I needed to use purchase event for a website, but at this point there was no possibility to hard code anything directly to the site (at least quick enough). Again, my rescue was to use Adobe’s script to which I had access through cloud service. Yes, tag management with old school way. 🙂

Luckily there was one word (e.g. “orderdone”) in the url always when the purchase was made, and I could make a javascript hack to populate the purchase event for Adobe Analytics.

if (/\/orderdone\//i.test(window.location.pathname) && (s.events))
{s.events +=",purchase"; }
else if (/\/orderdone\//i.test(window.location.pathname))
{s.events="purchase";}

The script checks if there is “orderdone” in the url-address (using so called “i.test” method) and if s.events already exists -> add “,purchase” with “,” sign to s.events and that way the variable doesn’t break if it already included some values. If s.events doesn’t exists then we just add the one “purchase” value to s.events. Makes sense? I know, there is always danger that something changes in the confirmation url and my script stops to work, that’s why always better to hard code taggings to the site if possible.

Users could load the “order done” page many times or come back to the page after getting email confirmation about the order including the link to the “order done” page. That’s why it would be important to populate s.purchaseID variable on the “order done” page too and that way purchase event gets counted only once per purchaseID. Lucky me, ID was included in the url and I could code something like this to capture order ID to Adobe’s purchaseID variable:

if (/\/orderdone\//i.test(window.location.pathname)) s.purchaseID = decodeURIComponent(window.location.pathname.split('/')[2]);

With “split” I can split url-address to different sections/folders and then I just choose to save folder that includes the order ID.

Here comes the real learning and why I decided to write this blog post

You can’t see purchaseID variable in Adobe Analytics stats. That’s why just out of curiosity and for learning purpose I wanted to copy purchaseID to eVar variable to see that the event serialization is working just fine and I can see only one purchase event with every eVar that holds the value for purchaseID. I could easily copy purchaseID to eVar variable inside the script like this: s.eVar22 = s.purchaseID;

Here comes the suprise. If I looked the stats in eVar22:
1) abcd = 2 orders
2) xyz = 2 orders
3) cVd = 1 order
etc.

Damn! How could that be possible. Adobe’s event serialization is not working? I didn’t figure out anything myself and I had to contact Adobe’s ClientCare and after few emails I got the detailed answer. The count for purchase event is working just fine and the event serialization is working correctly with purchaseID. However, eVar variables are case insensitive by default. You can find more info in here. That’s why it treats “abcd” and “ABCD” as the same. PurchaseID is case sensitive, and it treats “abcd” and “ABCD” as two different values. I know it is not ideal situation that site generates same ID numbers with small and big characters. If I understood correctly, Adobe can change eVars to case sensitive too.

You should remember this with many other situations too. For example if you save search terms to eVar then “ipad” is the same as “IPAD”. I believe that makes sense by default, but always good to remember how the stats are fixed.

Not sure can anyone enjoy and learn from my “beautiful” custom javascript hacking, but decided to share anyway and since I’m just starting to learn javascript it is always good to write scripts many times and that way you remember things better etc. If you have more interest to study how Adobe’s event serialization works and what different possibilites there are available, you should read this great help article.

About Antti

Digital Analytics Manager specialized in Adobe Analytics, Online personalization, SEO, CRO...

2 thoughts on “Adobe Analytics event serialization & custom javascript coding for purchase event

  1. I stumbled upon the case insensitive eVar once too. Since then toLowerCase() if the different String comes from the same Visitor/Event. Sadly in the described case it won’t help.

Leave a Reply

Your email address will not be published. Required fields are marked *