Sha256: 7dfe6ebacdb365f2d066467dd2beadde3f4ef0e9b78ef1f5e1258fc0753b2345

Contents?: true

Size: 1.34 KB

Versions: 121

Compression:

Stored size: 1.34 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_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

121 entries across 121 versions & 1 rubygems

Version Path
govuk_publishing_components-55.1.0 lib/govuk_publishing_components/presenters/layout_footer_helper.rb
govuk_publishing_components-55.0.1 lib/govuk_publishing_components/presenters/layout_footer_helper.rb
govuk_publishing_components-55.0.0 lib/govuk_publishing_components/presenters/layout_footer_helper.rb
govuk_publishing_components-54.0.1 lib/govuk_publishing_components/presenters/layout_footer_helper.rb
govuk_publishing_components-54.0.0 lib/govuk_publishing_components/presenters/layout_footer_helper.rb
govuk_publishing_components-53.0.0 lib/govuk_publishing_components/presenters/layout_footer_helper.rb
govuk_publishing_components-52.1.0 lib/govuk_publishing_components/presenters/layout_footer_helper.rb
govuk_publishing_components-52.0.0 lib/govuk_publishing_components/presenters/layout_footer_helper.rb
govuk_publishing_components-51.2.1 lib/govuk_publishing_components/presenters/layout_footer_helper.rb
govuk_publishing_components-51.2.0 lib/govuk_publishing_components/presenters/layout_footer_helper.rb
govuk_publishing_components-51.1.1 lib/govuk_publishing_components/presenters/layout_footer_helper.rb
govuk_publishing_components-51.1.0 lib/govuk_publishing_components/presenters/layout_footer_helper.rb
govuk_publishing_components-51.0.0 lib/govuk_publishing_components/presenters/layout_footer_helper.rb
govuk_publishing_components-50.0.1 lib/govuk_publishing_components/presenters/layout_footer_helper.rb
govuk_publishing_components-50.0.0 lib/govuk_publishing_components/presenters/layout_footer_helper.rb
govuk_publishing_components-49.1.0 lib/govuk_publishing_components/presenters/layout_footer_helper.rb
govuk_publishing_components-49.0.0 lib/govuk_publishing_components/presenters/layout_footer_helper.rb
govuk_publishing_components-48.0.0 lib/govuk_publishing_components/presenters/layout_footer_helper.rb
govuk_publishing_components-47.0.0 lib/govuk_publishing_components/presenters/layout_footer_helper.rb
govuk_publishing_components-46.4.0 lib/govuk_publishing_components/presenters/layout_footer_helper.rb