Here's another way using vertices, as those are connected to their respective primitive,
one handle each primitive (spline segment) individually. There you would set your Attribute
Create Node to use Vertex as the Class and type in $VTX/$NVTX for getting values going from 0 to 1
and after that use an Attribute Promote to get those values into the points Color. See screenshot.
After that just plug in a Color Node, set it to Ramp from Attribute, type in Cd as the attribute and
colorize to your hearts content.