Expand my Community achievements bar.

SOLVED

substring data in eVAR

Avatar

Level 1

Hi all,

Please can you advice if there is a solution for the below.

 

in a eVar, data is present as

 

eVar11

---------

x_PID:2

y_PID:3

z_PID:4

 

 

want

-------

2

3

4

 

Is this achievable

1 Accepted Solution

Avatar

Correct answer by
Level 10

There are two approaches you could use. 

You could use a classification such as ^.*:(\d+). Classifications come in two flavors. The easiest is the Classification Rule Builder. There are several steps involved in setting up a classification with the Rule Builder. Here are the instructions of how to do that: https://experienceleague.adobe.com/docs/analytics/components/classifications/classifications-rulebui...

Alternatively, you could use a list var. This looks for a delimiter (: in this case) and splits the values in the evar based on the delimiter. So the evar would look something like:

  • x_PID
  • 2
  • y_PID
  • 3
  • z_PID
  • 4

This method is not backwards compatible and is perhaps overkill for what you want to do. Go to Analytics > Admin >Report Suites > Edit Settings > Conversion > List Variables. Here are the instructions: https://experienceleague.adobe.com/docs/analytics/admin/admin-tools/manage-report-suites/edit-report...

 

 

 

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

There are two approaches you could use. 

You could use a classification such as ^.*:(\d+). Classifications come in two flavors. The easiest is the Classification Rule Builder. There are several steps involved in setting up a classification with the Rule Builder. Here are the instructions of how to do that: https://experienceleague.adobe.com/docs/analytics/components/classifications/classifications-rulebui...

Alternatively, you could use a list var. This looks for a delimiter (: in this case) and splits the values in the evar based on the delimiter. So the evar would look something like:

  • x_PID
  • 2
  • y_PID
  • 3
  • z_PID
  • 4

This method is not backwards compatible and is perhaps overkill for what you want to do. Go to Analytics > Admin >Report Suites > Edit Settings > Conversion > List Variables. Here are the instructions: https://experienceleague.adobe.com/docs/analytics/admin/admin-tools/manage-report-suites/edit-report...

 

 

 

Avatar

Level 2

@DennisUl1  I would recommend you to use a regex within your rule where you set this eVar to split and just return the numeric value right after the colon. Here is the sample code:

 

var inputString = "y_PID:3"; //in real work you need to read it from data layer
const regex = /:(\d+)/;
s.eVar11 = inputString.match(regex)[1];