As you mentioned that mid is available in querystring parameter, you can fetch the mid from querystring using function s.Util.getQueryParam and assign to evar.
Util.getQueryParam
Other method as suggested by Andrey, you can use eVar1="D=mid"; to pull the mid and assign it directly from analytics server call mid parameter to evar.