Expand my Community achievements bar.

Applications for the 2024 Adobe Target Community Mentorship Program are open! Click to the right to learn more about participating as either an Aspirant, to professionally level up with a new Certification, or as a Mentor, to share your Adobe Target expertise and inspire through your leadership! Submit your application today.
SOLVED

Way to run offer JS function when conversion is made?

Avatar

Level 1

Hi there,

I have a test that I'm trying to write where I need to take the last value of a variable before a conversion is made and pass it on to the server. Since I need the last value (and ONLY the last value), I need the javascript function in the offer code to run once the conversion has been made to ensure accuracy of results. Is there a way to invoke an offer's function right after a conversion is made?

Thanks!

1 Accepted Solution

Avatar

Correct answer by
Employee

Hi Genevieve,

I have a few follow-up questions about what you are trying to accomplish, but perhaps I can provide a few different answers to possible scenarios.

Updating the Profile

If you are hoping to store the variable with the user's profile, this can be accomplished "profile scripts."  Profile scripts allow you to apply logic on top of any call to our system (see documentation here) and store the value within the user's profile. Example use-case: every time a customer purchases, increment their total_dollars_spent value within their profile.

The logic you will want to apply is to save a particular value when the conversion event fires. A conversion event can be identified looking for any call with one of the following parameters: orderId, orderTotal, or productPurchasedId (see documentation here).

Writing a dynamic values in your offer

You can pass information about the activity, the experience, the user's profile, and more by following the instructions here. This would allow you to (1) register the conversion, (2) run JS logic on the conversion event and write a value to the user's profile, (3) return a value from the activity, the experience, or the user's profile directly to the page (or server).

Hopefully that helps.

View solution in original post

1 Reply

Avatar

Correct answer by
Employee

Hi Genevieve,

I have a few follow-up questions about what you are trying to accomplish, but perhaps I can provide a few different answers to possible scenarios.

Updating the Profile

If you are hoping to store the variable with the user's profile, this can be accomplished "profile scripts."  Profile scripts allow you to apply logic on top of any call to our system (see documentation here) and store the value within the user's profile. Example use-case: every time a customer purchases, increment their total_dollars_spent value within their profile.

The logic you will want to apply is to save a particular value when the conversion event fires. A conversion event can be identified looking for any call with one of the following parameters: orderId, orderTotal, or productPurchasedId (see documentation here).

Writing a dynamic values in your offer

You can pass information about the activity, the experience, the user's profile, and more by following the instructions here. This would allow you to (1) register the conversion, (2) run JS logic on the conversion event and write a value to the user's profile, (3) return a value from the activity, the experience, or the user's profile directly to the page (or server).

Hopefully that helps.