Skip to main content
Level 5
Oct 8, 2026 5:46 PM UTC
Question

Marketo Segmentation Not Working in Velocity Scripting

Hi Team,

We have a segmentation in Marketo that was working correctly during our initial testing, but it is now not working as expected. We have not made any changes to the segmentation.

The same segmentation is also causing an issue when used in another campaign. The email is always going to the else condition, and the if condition is not triggering.

I tested other segmentations, and they are working as expected. This particular segmentation is used through a Velocity Script , which was previously tested and worked correctly.

I also tried unapproving and reapproving the segmentation, but this did not resolve the issue.

#set( $portalsegment = ${lead.Segmentation_CustomerPortalSegment_1018} )
#set ($ContactId = ${lead.contactid})
#if( $portalsegment && $portalsegment.trim() == "Portal Status Is Active" )
DISPLAY A
#else
DISPLAY B
#end


Let me know if you need more details , happy to share :)

Looking forward to your help on this !!

Regards,
Akshat

8 replies

sandy_logitech
Level 4
Oct 8, 2026 6:51 PM UTC

Please insert code using the syntax highlighter in the future so it’s readable.

 

  1. You don’t need any curly braces in this code. It’s just making it less readable.
  2. You don’t need the falsiness check (if $portalsegment). It’s impossible for the value to be non-falsy.
  3. You don’t need to trim(). Marketo uses the real name of each Segment, it doesn’t pad the name.
  4. You shouldn’t use ==, use .equals().
  5. What is the value of $portalsegment here. You have to show us lower-level debugging info or we have nothing to go on.
Translate
ashah123Author
Level 5
Oct 12, 2026 2:23 PM UTC

​@sandy_logitech  Let me know if this helps !!

 

#set( $portalsegment = ${lead.Segmentation_CustomerPortal_1018Name} )#set ($ContactId = ${lead.contactid})#if( $portalsegment && $portalsegment.trim() == "Portal Status Is Active" )SHOW A#elseSHOW B#end

 

The Portal segmentation is based on the Portal Status string field, which contains three possible values: Active, Inactive, and Empty status. We use these values as filters to define the segments.

Could you please guide me on how the Velocity code should be updated to handle this segmentation correctly? We have been using the same scripting approach in our Velocity code, and it has been working as expected. The issue appears to be isolated to this specific segmentation, while the other segmentations continue to work as expected.

Could you please recommend the appropriate code changes or share any relevant documentation that could help us troubleshoot this issue?

 

Thanks alot for your help on this !!

Translate
sandy_logitech
Level 4
Oct 12, 2026 7:31 PM UTC

Again, what is the value of $portalsegment here? It doesn’t suffice to show code without its inputs.

Translate
ashah123Author
Level 5
Oct 13, 2026 10:14 AM UTC

I found the fix, thanks ​@sandy_logitech 

Translate
sandy_logitech
Level 4
Oct 13, 2026 5:00 PM UTC

What was it?

Translate