I realize this is an old thread, but I think there is an easier way to accomplish this with gtag.js. Go to tag mappings In the variables dropdown select "Use Custom Value" Type in "clientId" in the top left hand input box. This value really doesn't matter. Click "Add Custom Dimension" Type in "cdm.dimensionXX-clientId" Replace "XX" with the custom dimension number you want to populate. Click Done, Apply and Publish.
... View more