The answer from @mbalparda indeed answers your original question. However, based on the comments, it sounds like what you really need is a layout.
If you placed the code in the footer.phtml
template file you'll have a hard time removing it on the success page. In that case we'll create a layout instruction so that we can remove it once we're on the success page.
1. Create two static blocks
Name them google-trusted-general
and google-trusted-success
. Place your scripts (script tag and all) into each.
2. Update (or create) your local.xml theme layout
In your theme's layout folder add this to your local.xml
file (if it doesn't exist, create it):
<?xml version="1.0"?>
<layout>
<default>
<reference name="before_body_end">
<block type="cms/block" name="trusted">
<action method="setBlockId"><block_id>google-trusted-general</block_id></action>
</block>
</reference>
</default>
<checkout_onepage_success>
<reference name="before_body_end">
<remove name="trusted"/>
</reference>
<reference name="checkout.success">
<block type="core/text" as="trusted" name="trusted">
<block type="cms/block" name="trusted">
<action method="setBlockId"><block_id>google-trusted-success</block_id></action>
</block>
</block>
</reference>
</checkout_onepage_success>
</layout>
This will add the script to the entire site and remove on the success page, displaying a new block.