Integration: Cart Value
If you want to display content to users who currently have a particular cart value (to qualify for free shipping, for example), you need to pass that cart value in instrumentation.
Once you’ve instrumented your site, this feature will appear as a targeting parameter in the Personalization Cloud dashboard.
Note: Your Client Solutions Engineer must also enable this feature for your account. Be sure to talk to them if you’d like to implement it.
JavaScript Integration
How To Make This Code Work For You
- Create the integration code on each of the pages on your site, following the HTML integration and JSON integration guides.
- Add this function to your integration code:
Function | Requirement |
---|---|
R3_COMMON.setCartValue(VALUE); |
Replace VALUE with the current value of the shopper’s cart. The value is given in cents, meaning if current cart value is $100.99, the value provided should be 10099 . |
Sample Code
Call setCartValue()
in the Primary Code Block.
HTML
<!-- Put this code inside the <body> element as close to the top as possible --> <script src="//media.richrelevance.com/rrserver/js/1.0/p13n.js"></script> <script charset="utf-8" type="text/javascript"> var R3_COMMON = new r3_common(); R3_COMMON.setApiKey('abcd5432e1'); R3_COMMON.setBaseUrl(window.location.protocol+'//integration.richrelevance.com/rrserver/'); R3_COMMON.setClickthruServer(window.location.protocol+"//"+window.location.host); R3_COMMON.setSessionId('6B4D397B'); R3_COMMON.setUserId('1'); // if exists, set it; if not, set it as session ID // here's an example requesting recommendations for 1 page area R3_COMMON.addPlacementType('home_page.rr1'); var R3_HOME = new r3_home(); R3_COMMON.setCartValue(4799); r3(); </script>
JSON
<!-- Put this code inside the <body> element as close to the top as possible --> <script charset="utf-8" type="text/javascript"> var R3_COMMON = new r3_common(); R3_COMMON.setApiKey('abcd5432e1'); R3_COMMON.setBaseUrl(window.location.protocol+'//integration.richrelevance.com/rrserver/'); R3_COMMON.setClickthruServer(window.location.protocol+"//"+window.location.host); R3_COMMON.setSessionId('6B4D397B'); R3_COMMON.setUserId('10987'); // if exists, set it; if not, set it as session ID // here's an example requesting recommendations for 1 page area R3_COMMON.addPlacementType('home_page.rr1'); var R3_HOME = new r3_home(); R3_COMMON.setCartValue(4799); rr_flush_onload(); r3(); </script>
APIs
In personalize and recsForPlacements API use the cv
parameter to supply cart value.