> ## Documentation Index
> Fetch the complete documentation index at: https://shortpen.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# How to create Code-Triggered events in ShortPen

> Create code-triggered events in ShortPen to track actions like signups or purchases directly from your site or app.

**Short answer:** Create an event, choose **With code**, copy the JavaScript snippet on the page or action you want to track. Make sure the ShortPen Pixel is installed and the link has **Enable Tracking Events** turned on.

<Info>
  **Don't know what Code-Triggered events are?** Learn more: [Understanding Events and Conversions in ShortPen](/key-concepts/events-and-conversions-overview)
</Info>

## Before you start

* [**ShortPen Pixel installed**](/getting-started/install-shortpen-pixel) on your site. Events require the Pixel.
* [Event tracking enabled](/link-management/links-settings/enabling-event-tracking) **on the link**  that will receive conversions. Conversions start only after the event exists.
* **Access to your site/app code** (you’ll paste a small JS snippet).

## How to trigger an event with code: Steps

<Steps>
  <Step title="Create the event">
    Go to **Events → New Event**, name it clearly (e.g., **Signup**), select **With code**, then **Next**.

    ***
  </Step>

  <Step title="Copy the snippet">
    In **Trigger event by code**, click **Copy**.

    ***
  </Step>

  <Step title="Paste it where the action happens">
    Place the snippet on the page(s) or in the handler that confirms the action (e.g., after a form submit or purchase confirmation).

    ***
  </Step>

  <Step title="Save the event">
    Click **Save** to finalize the configuration.

    ***
  </Step>

  <Step title="Test it (real-time)">
    Open the [Event Testing Panel](/event-tracking/manage-events/events-testing) to confirm the event fires.
  </Step>
</Steps>

## FAQ

<AccordionGroup>
  <Accordion title="What’s the difference between URL-triggered and code-triggered events">
    URL-Triggered events fire when visitors land on a specific page (e.g., a thank-you URL). Code-triggered events fire via JavaScript when your app confirms an action. Both require the Pixel.

    <Info>
      **Learn more**: [Understanding Events and Conversions in ShortPen](/key-concepts/events-and-conversions-overview)
    </Info>
  </Accordion>

  <Accordion title="Do I need to recreate links to track a new event">
    No. If [Enable Tracking Events](/link-management/links-settings/enabling-event-tracking) is on for the link, new events will track from the moment they’re created, future actions only.
  </Accordion>
</AccordionGroup>

## Related links

* [How to create your first event in ShortPen](/getting-started/create-first-event)
* [How to create URL-Triggered events in ShortPen](/event-tracking/manage-events/url-triggered-events)
* [How to test ShortPen events with the Event Testing Panel](/event-tracking/manage-events/events-testing)
* [How to enable Event Tracking on a ShortPen Link](/link-management/links-settings/enabling-event-tracking)
* [Overview of ShortPen Analytics](/key-concepts/analytics-overview)
