I have a WordPress site running Gravity Forms and two existing PHP snippets that need quick corrections. My priorities are: 1. Fire a Google Tag Manager event the moment our API responds with a valid redirection URL. This event must trigger “when the API sends a valid response,” not on form submission or link click, so I can measure successful lead hand-offs. 2. Append the tracking parameters already present in the page URL—specifically gclid and gl—onto that redirection URL returned by the API to preserve cross-domain attribution. 3. Tighten the phone-number field: accept only numbers that begin with 06 or 07, enforce exactly 10 digits, and block any 0033/33 prefixes before the API sees the data. The existing snippets almost accomplish this but mis-fire the GTM event and mishandle the query-string merge; the phone rule also lets a few edge cases slip through. Please clean up the code, test on a staging form, and supply the fixed snippets with brief inline comments so I can drop them straight into functions.php or a custom plugin.