Sha256: bccd5d738a8510fcda2abae3458b62576e41cb91d0b6c7a5a638e19d12867707

Contents?: true

Size: 1.38 KB

Versions: 28

Compression:

Stored size: 1.38 KB

Contents

module GovukPublishingComponents
  module Presenters
    class LayoutFooterHelper
      attr_reader :ga4_index_section_count, :ga4_ogl_link_index_section, :ga4_copyright_link_index_section

      def initialize(footer_navigation_section, footer_meta_section)
        @ga4_index_section_count = footer_navigation_section.length
        @amount_of_meta_sections = 0

        if footer_meta_section.any?
          @amount_of_meta_sections = 1
          @ga4_index_section_count += 1
        end

        # For our GOVUK footer links, we need to add 2 to the index_section_count. This is due to the "Open Government License" and "Crown Copyright" links being defined separately to the rest of our footer links.
        @ga4_index_section_count += 2

        @ga4_ogl_link_index_section = footer_navigation_section.length + @amount_of_meta_sections + 1
        @ga4_copyright_link_index_section = @ga4_ogl_link_index_section + 1
      end

      def generate_ga4_link_attribute(index_link, index_section, section, index_total)
        {
          "event_name": "navigation",
          "type": "footer",
          "index": {
            "index_link": (index_link + 1).to_s,
            "index_section": (index_section + 1).to_s,
            "index_section_count": @ga4_index_section_count.to_s,
          },
          "index_total": index_total.to_s,
          "section": section,
        }
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
govuk_publishing_components-35.19.0 lib/govuk_publishing_components/presenters/layout_footer_helper.rb
govuk_publishing_components-35.18.0 lib/govuk_publishing_components/presenters/layout_footer_helper.rb
govuk_publishing_components-35.17.0 lib/govuk_publishing_components/presenters/layout_footer_helper.rb
govuk_publishing_components-35.16.1 lib/govuk_publishing_components/presenters/layout_footer_helper.rb
govuk_publishing_components-35.16.0 lib/govuk_publishing_components/presenters/layout_footer_helper.rb
govuk_publishing_components-35.15.5 lib/govuk_publishing_components/presenters/layout_footer_helper.rb
govuk_publishing_components-35.15.4 lib/govuk_publishing_components/presenters/layout_footer_helper.rb
govuk_publishing_components-35.15.3 lib/govuk_publishing_components/presenters/layout_footer_helper.rb
govuk_publishing_components-35.15.2 lib/govuk_publishing_components/presenters/layout_footer_helper.rb
govuk_publishing_components-35.15.1 lib/govuk_publishing_components/presenters/layout_footer_helper.rb
govuk_publishing_components-35.15.0 lib/govuk_publishing_components/presenters/layout_footer_helper.rb
govuk_publishing_components-35.14.0 lib/govuk_publishing_components/presenters/layout_footer_helper.rb
govuk_publishing_components-35.13.2 lib/govuk_publishing_components/presenters/layout_footer_helper.rb
govuk_publishing_components-35.13.1 lib/govuk_publishing_components/presenters/layout_footer_helper.rb
govuk_publishing_components-35.13.0 lib/govuk_publishing_components/presenters/layout_footer_helper.rb
govuk_publishing_components-35.12.0 lib/govuk_publishing_components/presenters/layout_footer_helper.rb
govuk_publishing_components-35.11.0 lib/govuk_publishing_components/presenters/layout_footer_helper.rb
govuk_publishing_components-35.10.0 lib/govuk_publishing_components/presenters/layout_footer_helper.rb
govuk_publishing_components-35.9.0 lib/govuk_publishing_components/presenters/layout_footer_helper.rb
govuk_publishing_components-35.8.0 lib/govuk_publishing_components/presenters/layout_footer_helper.rb