More haste, less speed. Please read the question more carefully.
...early in the head
I have plenty of ways to add javascript to the body. However, unless it's in the head, users see the original page, then a flash to a new page (because the script does a redirect after encoding an extra attribute in the URL).
I ... wrapped my code in an 'if' ... But this surely can't be the proper approach
So, telling me "you'd need to add a condition" is what I've already done, and the question was asking how it should be done
without a condition.
If it can't be done with CB, pls just say.