<% if accordion_content.present? %>
  <div class="grid-row child-topic-contents">
    <div class="column-two-thirds">
      <div class="topic-content">

        <div data-module="accordion-with-descriptions" class="js-hidden">
          <div class="subsection-wrapper">

            <% accordion_content.each_with_index do |taxon, index| %>
              <div class="subsection js-subsection" id="<%= taxon.base_path %>">
                <div class="subsection-header js-subsection-header">
                  <h2 class="subsection-title js-subsection-title"><%= taxon.title %></h2>
                  <% if taxon.description.present? %>
                    <p class="subsection-description"><%= taxon.description %></p>
                  <% end %>
                </div>

                <div class="subsection-content js-subsection-content" id="subsection_content_<%= index + 1 %>">
                  <% unless taxon.to_hash['has_tagged_content?'] %>
                    <%= render partial: 'email_alerts', locals: { taxon: taxon } %>
                  <% end %>
                  <%= render partial: 'content_list_for_child_taxon', locals: {
                      section_index: index,
                      tagged_content: taxon.tagged_content,
                  } %>
                </div>
              </div>
            <% end %>

          </div>
        </div>
      </div>
    </div>
  </div>
<% end %>

<% if accordion_content.present? %>
  <div class="grid-row child-topic-contents">
    <div class="column-two-thirds">
      <div class="topic-content">

        <div data-module="accordion-with-descriptions" class="js-hidden">
          <div class="subsection-wrapper">

            <% accordion_content.each_with_index do |taxon, index| %>
              <div class="subsection js-subsection" id="<%= taxon.base_path %>" data-track-count="accordionSection">
                <div class="subsection-header js-subsection-header">
                  <h2 class="subsection-title js-subsection-title"><%= taxon.title %></h2>
                  <% if taxon.description.present? %>
                    <p class="subsection-description"><%= taxon.description %></p>
                  <% end %>
                </div>

                <div class="subsection-content js-subsection-content" id="subsection_content_<%= index + 1 %>">
                  <% unless taxon.to_hash['has_tagged_content?'] %>
                    <%= render partial: 'email_alerts', locals: { taxon: taxon } %>
                  <% end %>
                  <%= render partial: 'content_list_for_child_taxon', locals: {
                      section_index: index,
                      tagged_content: taxon.tagged_content,
                  } %>
                </div>
              </div>
            <% end %>

          </div>
        </div>
      </div>
    </div>
  </div>
<% end %>

Add count tracking attribute for accordion sections
Add count tracking attribute for accordion sections

In order to count the number of accordion sections for tracking,
add a data attribute to the subsections, so we don’t have to rely
on fragile CSS class/tag name selectors for counting.
