Accessing Customer Attributes in Offer code dynamically

rajneesh_gautam 04-08-2017

Hi all, can someone please confirm the syntax of how customer attributes' value can be directly retrieved in the offer code? We use following syntax to access values of profile attributes : ${profile.your-profile-attribute}

For customer attribute, I am trying ${crs.data-source-name.attribute-name} but it doesn't seem to be working. Would appreciate a swift response here - thanks,

Regards,

Rajneesh

Accepted Solutions (1)

Accepted Solutions (1)

Amelia_Waliany
Employee
07-08-2017

Hi Rajneesh,

The Customer attributes can be referenced in profile scripts using format: crs.get(‘<Datasource Name>.<Attribute Name>‘). This profile script can be used directly in Offers for delivering Attributes that belong to the current visitor.

You can save the customer attribute as a profile script using this syntax: "crs.get(‘<Datasource Name>.<Attribute Name>‘)", and then reference the profile script in an offer using this syntax: ${user.your-profile-attribute}. Hope this helps!

Warmly,

Amelia

Answers (6)

Answers (6)

rajneesh_gautam 07-08-2019

Hi @mattk84335255, you can use following code in Target offer to fetch a customer-attribute value directly:

var a = "${crs.<integration-name>.<customer-attribute-name>}"

Note that <integration-name> is name of Customer Attributes Integration and NOT the alias-id.

Hope it helps,

Rajneesh

rajneesh_gautam 12-08-2019

Hi there, yes - this is done dynamically as Target evaluates Customer Attributes similar to Profile Attributes as each mbox request. Will suggest testing your code to ensure you are getting expectes results.

Regards,

Rajneesh

mattk84335255 08-08-2019

Hi rajneesh_gautam

OK so I think I'm almost there but can you just help me polish the last part and understand how to ensure I make this customer attribute a dynamic token?

the integration name is: custdata-xxx

the customer-attribute-name is:  CTRL_PCENTILE

==================================================

you can use following code in Target offer to fetch a customer-attribute value directly:

var a = "${crs.custdata-xxx.CTRL_PCENTILE}"

while using dynamic tokens in offer-code, you can provide default value like this:

var x = ${user.CTRL_PCENTILE default="default_val"};  // Setting default value for profile attribute CTRL_PCENTILE

How do I make my customer attribute 'CTRL_PCENTILE' into a token is is this done automatically?

Thanks (I owe you a decent coffee!)

Matt

rajneesh_gautam 08-08-2019

Hi @mattk84335255, while using dynamic tokens in offer-code, you can provide default valie like this:

var x = ${user.x default="default_val"};  // Setting default value for profile attribute x

Hope this helps,

Regards,

Rajneesh

mattk84335255 07-08-2019

Thanks rajneesh_gautam​ for the steer. 

In the scenario that the user to the page doesnt have a <customer-attribute-name> how could I then instead show a default value instead of the pulled through <customer-attribute-name>

If you could provide an example code I would include in the HTML Offer I'll be massively grateful!

Thanks

Matt

mattk84335255 01-08-2019

hi Amelia, is this 'crs.get' actually a method in Target?

I just need to be able to show we can successfully show a custom attribute in a target activity whether that be an offer or injected as some simply html.

Can you please confirm on the easiest way of doing this in Target?  We've done the upload of the offline data into audience manager and made it available in Target as we can use the attributes to build audiences.

I just to show a value of one of the custom attributes in a served target activity.  i.e. the customers status for example (in progress, queued, no contact)

Thanks

Matt