0

I have been tasked with setting up Google Tag Gateway for the website at work, and am struggling to understand how to get this done. We use rails backend and ALB and Route53 to route requests to our application. We cannot use the automatic Cloudfront configuration for reasons.

I am trying to follow Google's manual guide.

I have routes setup

get '/metrics', to: 'google_tag_gateway#serve_tag'
get '/metrics/*path', to: 'google_tag_gateway#serve_tag'

And a controller, where proxy_google_tag builds a request with out G-xxxx code and returns the javascript from there.

 def serve_tag
    # 1. "?validate_geo=healthy"-> health check for geolocation validation
    # 2. "/metrics/healthy" -> health check for basic health check
    # 3. in production/dev, proxy directly from Google's fps.goog domain
    # 4. in development, we can redirect to Google directly
    if params[:validate_geo] == 'healthy' || request.path == '/metrics/healthy'
      render plain: 'ok', status: :ok
    elsif Rails.env.development?
      redirect_to build_google_tag_url, status: :temporary_redirect
    else
      proxy_google_tag
    end
  end

Is this setup correct? Is this the intended setup for Google Tag Gateway or should it be handled by the ALB somehow?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.