substring data in eVAR | Community
Skip to main content
New Participant
March 7, 2024
Solved

substring data in eVAR

  • March 7, 2024
  • 2 replies
  • 586 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by RobertBlakeley

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-rulebuilder/classification-rule-builder.html?lang=en

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-suite/conversion-variables/list-var-admin.html?lang=en

 

 

 

2 replies

rajdsingh
New Participant
March 8, 2024

@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];

 

 

RobertBlakeley
RobertBlakeleyAccepted solution
New Participant
March 7, 2024

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-rulebuilder/classification-rule-builder.html?lang=en

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-suite/conversion-variables/list-var-admin.html?lang=en