Expand my Community achievements bar.

SOLVED

DTM - Configure Analytics in DTM - set s.purchaseID?

Avatar

Level 2

Hi,

I'm in DTM trying to write a Page Load rule that will set s.purchaseID to a javascript variable declared on the Order Confirmation page.  I can find s.campaign, eVars, props, events etc in the Adobe Analytics section of the rule builder, but not s.purchaseID.  Am I looking in the right place?

Thanks!

1 Accepted Solution

Avatar

Correct answer by
Level 2

Got a solution from Shawn C. Reed:

In Page Load Rules > Adobe Analytics > Custom Page Code [Open Editor]

I typed the following:

var s=window.s;
s.purchaseID=my_cart_id;

 

s.purchaseID is now firing with the data held in the var 'my_cart_id'

Thanks for the help everyone!

View solution in original post

4 Replies

Avatar

Level 2

Alternately, I've tried writing some custom scripts, but I can't seem to get any to fire.

I'm in Page Load Rule > Adobe Analytics > Custom Page Code [Open Editor] >

s.purchaseID=<javascript variable>;

e.g.

s.purchaseID=my_order_ID;

 

Am I missing anything?

Thanks!

Avatar

Employee

Hard to say for sure without looking at your code, but you'll probably want to set up that JavaScript variable as a Data Element in DTM.  JS Object is a built-in option, so you can simply enter the path for that variable. 

Once that is saved, you can reference the Data Element in custom script (you were entering it in the right place).  For example:

s.purchaseID = _satellite.getVar('name of your data element');

Right after that custom code, you may also want to use _satellite.notify('custom script fired', 1); or something like that for debugging purposes.  _satellite.notify() is a protected version of console.log().  You can look in the console and make sure that script fired as expected.

Hope that helps.  Let us know if that doesn't work for you.

Avatar

Level 2

Hi Erika,

Does it matter if I enter in the custom script via the Adobe Analytics section vs the Javascript section?

Other ideas I've heard involve writing the custom script prefaced with var s=window.s;

ex:

var s=window.s;
s.purchaseID=my_cart_id;

I've made a Data Element from the js variable on the page and named it my_cart_id.  Tried a custom script as:

s.purchaseID = _satellite.getVar('my_cart_id');

Does that look right, or should it be:

s.purchaseID = _satellite.getVar('%my_cart_id%');

?

Thanks!

Avatar

Correct answer by
Level 2

Got a solution from Shawn C. Reed:

In Page Load Rules > Adobe Analytics > Custom Page Code [Open Editor]

I typed the following:

var s=window.s;
s.purchaseID=my_cart_id;

 

s.purchaseID is now firing with the data held in the var 'my_cart_id'

Thanks for the help everyone!