Using JS to trim datalayer variable

Does this solve your issue?