<%= render layout: 'base_page', locals: {
  title: @publication.title,
  publication: @publication,
  edition: @edition,
} do %>
  <section class="intro">
    <div class="get-started-intro">

      <div class="find-nearest">

        <%= raw @publication.introduction %>

        <%= render partial: 'location_form', locals: { format: 'service' } %>
      </div>
    </div>
  </section>

  <% if @postcode.present? and !@publication.places.nil? %>
    <% if @publication.places.any? %>
      <section class="places">
        <h2>Results <%= preposition ||= "near" %> <strong><%= @postcode %></strong>:</h2>
        <ol id="options" class="places">
          <%= render partial: option_partial ||= "option", locals: { places: @publication.places } %>
        </ol>
      </section>
    <% else %>
      <div class="error-notification"><p>Sorry, no results were found near you.</p></div>
    <% end %>
  <% else %>
    <section class="more">
      <div class="further_information">
        <h2>Further information</h2>
        <%= raw @publication.need_to_know %>
        <%= raw @publication.more_information %>
      </div>
    </section>
  <% end %>
<% end %>

<%= render partial: 'ga_postcode_error_tracking', locals: { alert_type: 'place' } %>

<%= render layout: 'base_page', locals: {
  title: @publication.title,
  publication: @publication,
  edition: @edition,
} do %>
  <section class="intro">
    <div class="get-started-intro">

      <div class="find-nearest">

        <%= raw @publication.introduction %>

        <%= render partial: 'location_form', locals: { format: 'service' } %>
      </div>
    </div>
  </section>

  <% if @postcode.present? and !@publication.places.nil? %>
    <% if @publication.places.any? %>
      <section class="places"
               data-module="auto-track-event"
               data-track-category="placeSearch"
               data-track-action="postcodeResultShown"
               data-track-label="<%= @publication.places.first["name"] %>">
        <h2>Results <%= preposition ||= "near" %> <strong><%= @postcode %></strong>:</h2>
        <ol id="options" class="places">
          <%= render partial: option_partial ||= "option", locals: { places: @publication.places } %>
        </ol>
      </section>
    <% else %>
      <div class="error-notification"><p>Sorry, no results were found near you.</p></div>
    <% end %>
  <% else %>
    <section class="more">
      <div class="further_information">
        <h2>Further information</h2>
        <%= raw @publication.need_to_know %>
        <%= raw @publication.more_information %>
      </div>
    </section>
  <% end %>
<% end %>

<%= render partial: 'ga_postcode_error_tracking', locals: { alert_type: 'place' } %>

Add GA tracking for results shown with data module
Add GA tracking for results shown with data module

We implement GA tracking with data modules as described in govuk_frontend_toolkit (https://github.com/alphagov/govuk_frontend_toolkit/blob/master/docs/javascript.md#modules). We use the `auto-track-event` module defined in govuk_frontend_toolkit (https://github.com/alphagov/govuk_frontend_toolkit/blob/master/javascripts/govuk/modules/auto-track-event.js).

We also add the name of the first places results as a label for GA tracking. This allows for specific tracking of shown results in the DfE campaign to promote the "Report child abuse" page. For non-report-child-abuse cases this is not necessarily useful, but it is deemed as the best compromise to allow tracking for this specific campaign and may be extended in future (by sending all results) for other formats if useful.
