Skip to main content

Embedding Forms

You can embed a TrolleyShield custom form on any website using a script snippet or an iframe. The embed includes full behavioral tracking, AI analysis, and attribution capture.

The script embed renders the form directly in your page with behavioral tracking built in.

Setup

  1. Go to Forms in your TrolleyShield dashboard
  2. Click on the form you want to embed
  3. Copy the embed snippet

The snippet looks like this:

<div id="trolley-form-abc123"></div>
<script src="https://app.trolleyshield.com/custom-form.js"
data-form-id="abc123"
data-api-key="tsk_your_api_key"
async>
</script>
  1. Paste it into your website's HTML where you want the form to appear

How It Works

When the page loads, the script:

  1. Fetches the form configuration from TrolleyShield
  2. Renders the form inside the <div> container
  3. Attaches behavioral tracking (keystrokes, mouse movement, timing)
  4. On submit, sends form data + behavioral score + attribution to the API
  5. Displays a success message, redirects, or shows a block notice

Styling the Embed

The embed uses the styling settings you configured in the form builder. If you need full control over the form's appearance:

  1. Enable No Style Mode in the form builder's styling settings
  2. The form will render with only CSS class names (no inline styles)
  3. Target these classes in your stylesheet:
/* Form wrapper */
.ts-form { }

/* Form title */
.ts-form-title { }

/* Field wrapper */
.ts-form-field { }

/* Labels */
.ts-form-label { }

/* All inputs */
.ts-form-input { }

/* Specific input types */
.ts-form-textarea { }
.ts-form-select { }
.ts-form-checkbox { }
.ts-form-checkbox-label { }

/* Submit button wrapper and button */
.ts-form-submit-wrapper { }
.ts-form-submit { }

/* Success and error states */
.ts-form-success { }
.ts-form-error { }

Iframe Embed

If you prefer to embed the hosted page directly:

<iframe
src="https://app.trolleyshield.com/f/your-form-slug"
width="100%"
height="600"
frameborder="0"
style="border: none;">
</iframe>
tip

The script embed is preferred over iframe because it integrates more naturally with your page layout, supports full CSS customization, and doesn't have cross-origin restrictions on redirect success actions.

Attribution Tracking

Both embed methods automatically capture attribution data from the URL where the form is displayed:

ParameterSourceExample
page_urlCurrent page URLhttps://yoursite.com/landing?utm_source=google
referrerHTTP referrerhttps://google.com
utm_sourceURL parametergoogle
utm_mediumURL parametercpc
utm_campaignURL parameterspring-sale
utm_termURL parameterroof repair
utm_contentURL parameterad-variant-a
gclidURL parameterGoogle Ads click ID
gbraidURL parameterGoogle Ads app click ID
wbraidURL parameterGoogle Ads web-to-app click ID

This data appears in the Source Attribution card when you expand a submission in the Submissions table.

If your landing page URL contains a gclid parameter (auto-appended by Google Ads), the form will automatically capture it. This enables:

  • Seeing which Google Ads campaigns and keywords drive form leads
  • Matching form submissions back to specific ad clicks
  • Attribution data visible in the Submissions dashboard

No additional configuration is required — attribution capture is always on.

Behavioral Tracking

The embed script automatically tracks visitor behavior to detect bots and spam:

  • Typing patterns — keystroke timing, backspace frequency, paste detection
  • Mouse activity — movement count and patterns within the form
  • Time on page — how long the visitor spends before submitting
  • Field interaction — focus/blur events, field navigation order
  • Tab-away detection — whether the visitor switches browser tabs

This generates a behavioral score (0-100) that's combined with AI analysis for more accurate classification. No configuration needed — it runs automatically.

Failsafe Behavior

If the TrolleyShield API is unreachable when the form is submitted, the form fails open — it shows the success message or redirects as if the submission was accepted. This prevents legitimate users from being blocked by an API outage.

Next Steps