Get a Google Tag Manager dataLayer variable and autocompile a hidden field in a javascript application -- 2

Job ID: 36239246

Budget: €8 – €30 EUR

In this page https://wpcontest.ewebite.com/?ref=9c59b#cle44t5qo we need to autocompile the hidden field identified by id="custom_referral_code" that is present in this code row:
<input type="hidden" name="custom_referral_code" id="custom_referral_code" class="form-control" placeholder="referral_code" value="null" style="pointer-events: auto;">

The value must be the Google Tag Manager variable {{referral_code}} that is already present in the page and that is picked from the URL parameter ref (in the example, the ref parameter is 9c59b).

So, in the example where the ref=9c59b and the GTM dataLayer variable {{referral_code}} is 9c59b, we need to obtain this final row autocompiled:
<input type="hidden" name="custom_referral_code" id="custom_referral_code" class="form-control" placeholder="referral_code" value="9c59b" style="pointer-events: auto;">

We are using a quiz builder plugin called Smart Quiz Builder inside a Wordpress website.
This plugin has inside a Script section where you can put your script to be loaded by the tool in 4 different moments (On Load, After Start Button click, Upon Opt-in, After continue button click).

We need expert of GTM and Javascript. Please note that we will pay only for task completed as described, thanks.
Related categories: JavaScript WordPress jQuery Google Tag Management