My case is the following:

I need to output in the document a google analytics script after a custom contact form has been submitted, i have thought about many things like:

  • observers.
  • layout handles
  • using javascript ( this didn't worked)

How can I achieve this?

More details: After successful send, the controller doues a page redirect to the same url also outputs a success message.


Found a way to output a google script code or any script after a custom form has been saved, this controller makes a redirect to the same page and output a success message, used this function:

$output = $cms->setBlockId('my-custom-block')->toHtml();

The addSuccess($msg) function does not strip any html tag,I can insert a "p","script" tag without problems in the custom block content.

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.