How to get the data path of object dimensions for using in drivers?
You can use the object viewport color to transfer information to the material. Here it's convenient because the dimensions are always positive and the RGB channels can only hold positive values so we can just use the raw value.
You can either add a driver to each of the R, G, B channel of the viewport color property by hand or by using a script.
Use dimensions[0] for the $X$ dimension, dimensions[1] for $Y$ and dimensions[2] for $Z$.
Alternatively (and perhaps more intuitively) you can use dimensions.x, dimensions.y, dimensions.z.

Here is a script to automate it :
import bpy


def main():
    ao = bpy.context.active_object
    if not ao or ao.type not in  ('MESH', 'CURVE', 'SURFACE', 'META', 'FONT', 'VOLUME', 'GPENCIL'):
        print(&quot;Select a mesh, curve, surface, metaball, text, volume or grease pencil object&quot;)
        return
    for i in range(0, 3):
        add_driver_to(ao, &quot;color&quot;, &quot;dimensions&quot;, &quot;dim&quot;, i)
    

def add_driver_to(obj, prop_to, prop_from, var_name, dim):
    &quot;&quot;&quot;
    Add a driver to obj's prop_to property
    Using obj's prop_from property
    
    Both properties must be at least of dimension dim
    &quot;&quot;&quot;
    if not obj:
        return
    if not hasattr(obj, prop_to):
        print(f&quot;Object '{obj.name}' doesn't have a property named '{prop_to}'&quot;)
        return
    driver = obj.driver_add(prop_to, dim).driver
    # Make sure we don't add variables indefinitely :
    var = driver.variables.get(var_name)
    if not var:
        var = driver.variables.new()
    var.name = &quot;dim&quot;
    var.type = 'SINGLE_PROP'

    target = var.targets[0]
    target.id_type = 'OBJECT'
    target.id = obj
    target.data_path = f&quot;{prop_from}[{dim}]&quot;
    
    driver.expression = var_name

        
if __name__ == &quot;__main__&quot;:
    main()

To visualize what we just did, set the viewport object color to &quot;Object&quot;.

Execute the script and scale the object.

To access it in a shader access the &quot;Color&quot; output of the &quot;Object Info&quot; node and separate each channel.

Scale along X for example (Values &gt; 1 are pure white):