Extracting context root from a URL to tag it

If I understand correctly, you can try something like this, as the context root is metadata we detect OOTB: