> ## Documentation Index
> Fetch the complete documentation index at: https://docs-dev-actions-transaction-metadata.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Preserve Values on Redirect to External Sites

> Preserve transaction metadata during redirects. Values are available when users continue the authentication flow.

Preserve transaction metadata during [redirects](/docs/customize/actions/explore-triggers/signup-and-login-triggers/login-trigger/redirect-with-actions). Values are available when users continue the authentication flow.

**Action 1**

Sets a `custom_tx_id` in the transaction metadata.

```javascript lines theme={null}
exports.onExecutePostLogin = async (event, api) => {
  api.transaction.setMetadata('custom_tx_id', 'xyz123');
};
```

**Action 2**

Redirects to an external site sending a token with the `custom_tx_id` from the transaction metadata. Then it compares the `custom_tx_id` value at the transaction metadata with the one passed to the external site that has been sent back in the payload of another token.

```javascript lines theme={null}
exports.onExecutePostLogin = async (event, api) => {
  const token = api.redirect.encodeToken({
    secret: event.secrets.REDIRECT_SECRET,
    expiresInSeconds: 60, 
    payload: {
      custom_tx_id: event.transaction?.metadata?.custom_tx_id,
      continue_uri: `https://${event.secrets.TENANT_DOMAIN}/continue`
    },
  });

  api.redirect.sendUserTo(event.secrets.REDIRECT_URL, {
    query: { session_token: token }
  });
};

exports.onContinuePostLogin = async (event, api) => {
  const payload = api.redirect.validateToken({
    secret: event.secrets.REDIRECT_SECRET
  });

  console.log('Does custon_tx_id match?',
    payload?.custom_tx_id === event.transaction?.metadata?.custom_tx_id
  );
  /* Outputs "Does custon_tx_id match? True" */
};
```
