Expand my Community achievements bar.

Submissions are now open for the 2026 Adobe Experience Maker Awards
SOLVED

How to achieve processing rules functionality to set a data variable value in adobe analytics based in certain conditions?

Avatar

Level 2

I want to create a condition/rule in Adobe Analytics which will set the value of a variable "pageName" based on the pageURL values received.

for E.g if pageURL contains /?xyz then I want the pageName value to be "A" , if pageUrl contains /abc then pageName should be set to "B" and so on.

I know there are processing rules we can use to achieve this in adobe analytics but I was wondering if there is any other way apart from this. Also, by using processing rules can we set multiple IF-ELSE conditions in a single rule?

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor and Adobe Champion

Hi @Kshg7030,

 

Is this for a website, or for a mobile app?

 

For both, yes you could use Processing Rules, and yes, you have limited control to set up if logic (there is no true "else" logic, but you can order the rules and add conditions to catch various scenarios).

 

If this is for a mobile app, this is likely your only option; assuming of course that you don't just tell your developers what values to send under what conditions and test it to make sure it works as expected.

 

And in case you say "but mobile apps don't have URLs....", ALL our mobile apps set the equivalent URL in the tracking.

 

 

Now, if you are talking about web, I wouldn't use processing rules... I would use Adobe Launch, and use a custom code Data Element to write out the logic of what you want (actually, this isn't even a "I would" situation, this is exactly what I do... though less based on the URL, and more based on a series of factors like what is the page type, and other data layer values that I have at my disposal)

 

Essentially, I create a custom code Data Element like so:

Jennifer_Dungan_0-1756316071034.png

 

 

Then in the code editor, I will code the logic:

var url = _satellite.getVar('url');  // assuming you have a data element for the url]
var pagename = "unknown";

if (url.indexOf('/?xyz') > -1){
  pagename = "a";
}
else if (url.indexOf('/abc') > -1){
  pagename = "b";
}
....

return pagename;

 

The _statellite.getVar statement gets the value of "url" Data Element... while yes you could reference this through all your code (in all the if statements), it's less efficient to keep retrieving the value then to just set a variable that you can use in your logic (and if you need the test or change something, it's easier to change one line than everywhere in your code).

 

I like the set an initial pagename of "unknown" so that I can monitor if something is slipping past the logic that isn't setting a proper name... you don't have to do that, you could just set it to an initial value of ""

 

The return statement sets the final value to the Data Element, then I can use the data element as any other DE in my implementation. 

View solution in original post

3 Replies

Avatar

Correct answer by
Community Advisor and Adobe Champion

Hi @Kshg7030,

 

Is this for a website, or for a mobile app?

 

For both, yes you could use Processing Rules, and yes, you have limited control to set up if logic (there is no true "else" logic, but you can order the rules and add conditions to catch various scenarios).

 

If this is for a mobile app, this is likely your only option; assuming of course that you don't just tell your developers what values to send under what conditions and test it to make sure it works as expected.

 

And in case you say "but mobile apps don't have URLs....", ALL our mobile apps set the equivalent URL in the tracking.

 

 

Now, if you are talking about web, I wouldn't use processing rules... I would use Adobe Launch, and use a custom code Data Element to write out the logic of what you want (actually, this isn't even a "I would" situation, this is exactly what I do... though less based on the URL, and more based on a series of factors like what is the page type, and other data layer values that I have at my disposal)

 

Essentially, I create a custom code Data Element like so:

Jennifer_Dungan_0-1756316071034.png

 

 

Then in the code editor, I will code the logic:

var url = _satellite.getVar('url');  // assuming you have a data element for the url]
var pagename = "unknown";

if (url.indexOf('/?xyz') > -1){
  pagename = "a";
}
else if (url.indexOf('/abc') > -1){
  pagename = "b";
}
....

return pagename;

 

The _statellite.getVar statement gets the value of "url" Data Element... while yes you could reference this through all your code (in all the if statements), it's less efficient to keep retrieving the value then to just set a variable that you can use in your logic (and if you need the test or change something, it's easier to change one line than everywhere in your code).

 

I like the set an initial pagename of "unknown" so that I can monitor if something is slipping past the logic that isn't setting a proper name... you don't have to do that, you could just set it to an initial value of ""

 

The return statement sets the final value to the Data Element, then I can use the data element as any other DE in my implementation. 

Avatar

Level 2

Hi @Jennifer_Dungan , yeah this is for web SPA and not for mobile.

 

I am aware of how we can use adobe Launch here to send the desired value along with the analytics call. I just wanted to see if we have various ways to achieve this end goal, since this is an SPA website, we don't have multiple pageNames available from development end. So to use secondary options like launch and processing rules is the way here.

 

Thanks for your detailed response here. For now, I believe I will also go with using launch.

 

Avatar

Community Advisor and Adobe Champion

Yes, even for an SPA, Launch is the best way to control things... I assume you have some sort of data layer, and way to detect when pages change (either a custom event, or checking for a "history change").

 

Launch however gives you a lot more coding freedom, and is a lot easier to make changes (believe me.. I have to do complex logic for our apps in Processing Rules... I do it cause it makes it easier for me to control and not put the effort on devs... but it's also a bit of a pain to work with)