1

I would like to receive instructions on how to not echo Google Analytics JS when user browser send header "DNT".

I would like to know if:

  1. Would i have to make an extension on the GA block class to get the $_SERVER to check whether it should return null or the JS code
  2. Would there be any way to do that on XML
  3. Should i do it on the "display" (i mean the design/template)
2

1) Would i have to make an extension on the GA block class to get the $_SERVER to check whether it should return null or the JS code

Yes I think you need to add your own code. A way to detect the DNT header can be found from Robert Lerner

2) Would there be any way to do that on XML

I think no. What you could do is implement a helper and depending on the return value of the helper do something. So you could add a DNT-value to the block, you can check in the template and then do nothing

3) Should i do it on the "display" (i mean the design/template)

No, I would implement everything in your own block, check the DNT there and then just call the method in your template to do something - or not.

I think this is business logic and therefore it belongs in a model, controller, helper or block, but definitely not in a template.

I prefer the block over the helper.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.