AUTOMATE SEGMENT CODES | Community
Skip to main content
Level 3
June 13, 2024
Solved

AUTOMATE SEGMENT CODES

  • June 13, 2024
  • 1 reply
  • 679 views

Hi,

 

can someone explain me how to automate the creation of segment codes? Cant find any documentation about it...

Maybe using javascript?

 

Thank you and kind regards,

Blanca

 

 

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 ParthaSarathy

Hi @bcollado ,

Go to Split activity > Advanced tab > paste the below script in initialization script

vars.subset1_variable = formatDate(new Date(), "%4Y/%2M/%2D"); vars.complement_variable = formatDate(new Date(), "%4Y"); //for Subset 1 activity.transitions.extractOutput[0].code = vars.subset1_variable; //For complement segment code activity.transitions.remainder.code = vars.complement_variable;

The above script will automate segment code by adding current date to subset 1 and current year in complement's segment code. Instead of current date and year, replace it with your logic and store in the same above variable and run the workflow.

 

If you have multiple subsets, then add one more line and modify it as extractOutput[1], extractOutput[2] and so on...

//Subset 1 activity.transitions.extractOutput[0].code = vars.subset1_variable; //Subset 2 activity.transitions.extractOutput[1].code = vars.subset2_variable; //Subset 3 activity.transitions.extractOutput[2].code = vars.subset3_variable; //Subset 4 activity.transitions.extractOutput[3].code = vars.subset4_variable; //Complement activity.transitions.remainder.code = vars.complement_variable;

1 reply

ParthaSarathy
Community Advisor
ParthaSarathyCommunity AdvisorAccepted solution
Community Advisor
June 14, 2024

Hi @bcollado ,

Go to Split activity > Advanced tab > paste the below script in initialization script

vars.subset1_variable = formatDate(new Date(), "%4Y/%2M/%2D"); vars.complement_variable = formatDate(new Date(), "%4Y"); //for Subset 1 activity.transitions.extractOutput[0].code = vars.subset1_variable; //For complement segment code activity.transitions.remainder.code = vars.complement_variable;

The above script will automate segment code by adding current date to subset 1 and current year in complement's segment code. Instead of current date and year, replace it with your logic and store in the same above variable and run the workflow.

 

If you have multiple subsets, then add one more line and modify it as extractOutput[1], extractOutput[2] and so on...

//Subset 1 activity.transitions.extractOutput[0].code = vars.subset1_variable; //Subset 2 activity.transitions.extractOutput[1].code = vars.subset2_variable; //Subset 3 activity.transitions.extractOutput[2].code = vars.subset3_variable; //Subset 4 activity.transitions.extractOutput[3].code = vars.subset4_variable; //Complement activity.transitions.remainder.code = vars.complement_variable;
~  ParthaSarathy S~  Click here to join ADOBE CAMPAIGN USER GROUP for Quarterly In-person | Hybrid | Virtual Meetups
bcolladoAuthor
Level 3
June 14, 2024

Thank you very much!!

 

have a nice day 🙂