96 lines
5.9 KiB
PHP
96 lines
5.9 KiB
PHP
@php
|
|||
|
|
$goalType = old('type', $goal->type ?? '');
|
||
|
|
$conditions = old('conditions', $goal->conditions ?? []);
|
||
|
|
@endphp
|
||
|
|
|
||
|
|
<div x-data="{ goalType: '{{ $goalType }}' }" class="space-y-6">
|
||
|
|
<div>
|
||
|
|
<x-input-label for="name" value="Goal Name" />
|
||
|
|
<x-text-input id="name" name="name" type="text" class="mt-1 block w-full" :value="old('name', $goal->name ?? '')" required autofocus placeholder="e.g. Completed Signup" />
|
||
|
|
<x-input-error class="mt-2" :messages="$errors->get('name')" />
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<div>
|
||
|
|
<x-input-label for="type" value="Goal Type" />
|
||
|
|
<select id="type" name="type" x-model="goalType" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500" required>
|
||
|
|
<option value="">Select a type...</option>
|
||
|
|
<option value="url_destination">URL Destination</option>
|
||
|
|
<option value="event_match">Event Match</option>
|
||
|
|
<option value="duration">Session Duration</option>
|
||
|
|
<option value="pages_per_session">Pages per Session</option>
|
||
|
|
</select>
|
||
|
|
<x-input-error class="mt-2" :messages="$errors->get('type')" />
|
||
|
|
</div>
|
||
|
|
|
||
|
|
{{-- URL Destination fields --}}
|
||
|
|
<div x-show="goalType === 'url_destination'" x-cloak class="rounded-lg border border-gray-200 p-4 space-y-4">
|
||
|
|
<h4 class="text-sm font-medium text-gray-700">URL Destination Conditions</h4>
|
||
|
|
<div>
|
||
|
|
<x-input-label for="conditions_path" value="Path" />
|
||
|
|
<x-text-input id="conditions_path" name="conditions[path]" type="text" class="mt-1 block w-full" :value="$conditions['path'] ?? ''" placeholder="/thank-you" />
|
||
|
|
<x-input-error class="mt-2" :messages="$errors->get('conditions.path')" />
|
||
|
|
</div>
|
||
|
|
<div>
|
||
|
|
<x-input-label for="conditions_match_type" value="Match Type" />
|
||
|
|
<select id="conditions_match_type" name="conditions[match_type]" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500">
|
||
|
|
<option value="exact" @selected(($conditions['match_type'] ?? '') === 'exact')>Exact match</option>
|
||
|
|
<option value="starts_with" @selected(($conditions['match_type'] ?? '') === 'starts_with')>Starts with</option>
|
||
|
|
<option value="contains" @selected(($conditions['match_type'] ?? '') === 'contains')>Contains</option>
|
||
|
|
<option value="regex" @selected(($conditions['match_type'] ?? '') === 'regex')>Regex</option>
|
||
|
|
</select>
|
||
|
|
<x-input-error class="mt-2" :messages="$errors->get('conditions.match_type')" />
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
{{-- Event Match fields --}}
|
||
|
|
<div x-show="goalType === 'event_match'" x-cloak class="rounded-lg border border-gray-200 p-4 space-y-4">
|
||
|
|
<h4 class="text-sm font-medium text-gray-700">Event Match Conditions</h4>
|
||
|
|
<div>
|
||
|
|
<x-input-label for="conditions_event_name" value="Event Name" />
|
||
|
|
<x-text-input id="conditions_event_name" name="conditions[event_name]" type="text" class="mt-1 block w-full" :value="$conditions['event_name'] ?? ''" placeholder="signup" />
|
||
|
|
<x-input-error class="mt-2" :messages="$errors->get('conditions.event_name')" />
|
||
|
|
</div>
|
||
|
|
<div>
|
||
|
|
<x-input-label for="conditions_event_category" value="Event Category (optional)" />
|
||
|
|
<x-text-input id="conditions_event_category" name="conditions[event_category]" type="text" class="mt-1 block w-full" :value="$conditions['event_category'] ?? ''" placeholder="conversion" />
|
||
|
|
<x-input-error class="mt-2" :messages="$errors->get('conditions.event_category')" />
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
{{-- Duration fields --}}
|
||
|
|
<div x-show="goalType === 'duration'" x-cloak class="rounded-lg border border-gray-200 p-4 space-y-4">
|
||
|
|
<h4 class="text-sm font-medium text-gray-700">Duration Condition</h4>
|
||
|
|
<div>
|
||
|
|
<x-input-label for="conditions_seconds" value="Minimum seconds on site" />
|
||
|
|
<x-text-input id="conditions_seconds" name="conditions[seconds]" type="number" class="mt-1 block w-full" :value="$conditions['seconds'] ?? ''" min="1" placeholder="180" />
|
||
|
|
<p class="mt-1 text-xs text-gray-500">Goal completes when a session lasts at least this many seconds.</p>
|
||
|
|
<x-input-error class="mt-2" :messages="$errors->get('conditions.seconds')" />
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
{{-- Pages per Session fields --}}
|
||
|
|
<div x-show="goalType === 'pages_per_session'" x-cloak class="rounded-lg border border-gray-200 p-4 space-y-4">
|
||
|
|
<h4 class="text-sm font-medium text-gray-700">Pages per Session Condition</h4>
|
||
|
|
<div>
|
||
|
|
<x-input-label for="conditions_page_count" value="Minimum pages viewed" />
|
||
|
|
<x-text-input id="conditions_page_count" name="conditions[page_count]" type="number" class="mt-1 block w-full" :value="$conditions['page_count'] ?? ''" min="1" placeholder="5" />
|
||
|
|
<p class="mt-1 text-xs text-gray-500">Goal completes when a session views at least this many pages.</p>
|
||
|
|
<x-input-error class="mt-2" :messages="$errors->get('conditions.page_count')" />
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<div>
|
||
|
|
<x-input-label for="default_value" value="Goal Value (optional)" />
|
||
|
|
<x-text-input id="default_value" name="default_value" type="number" step="0.01" class="mt-1 block w-full" :value="old('default_value', $goal->default_value ?? '')" placeholder="0.00" />
|
||
|
|
<p class="mt-1 text-xs text-gray-500">Monetary value assigned to each conversion.</p>
|
||
|
|
<x-input-error class="mt-2" :messages="$errors->get('default_value')" />
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<div>
|
||
|
|
<label for="is_active" class="inline-flex items-center">
|
||
|
|
<input id="is_active" type="checkbox" name="is_active" value="1" class="rounded border-gray-300 text-indigo-600 shadow-sm focus:ring-indigo-500" {{ old('is_active', $goal->is_active ?? true) ? 'checked' : '' }}>
|
||
|
|
<span class="ms-2 text-sm text-gray-600">Active</span>
|
||
|
|
</label>
|
||
|
|
</div>
|
||
|
|
</div>
|