Like @bjoern__koth , I agree... you are manually defining the gtag, so you should be fine... there should be no issue with order of operation here, since the entirety of the code is right here (check for data layer, set it up if not already there, configure, etc)
I also suspect that the issue migh...