Class: GovukPublishingComponents::Presenters::LayoutFooterHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/govuk_publishing_components/presenters/layout_footer_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(footer_navigation_section, footer_meta_section) ⇒ LayoutFooterHelper

Returns a new instance of LayoutFooterHelper.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/govuk_publishing_components/presenters/layout_footer_helper.rb', line 6

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

Instance Attribute Details

Returns the value of attribute ga4_copyright_link_index_section.



4
5
6
# File 'lib/govuk_publishing_components/presenters/layout_footer_helper.rb', line 4

def ga4_copyright_link_index_section
  @ga4_copyright_link_index_section
end

#ga4_index_section_countObject (readonly)

Returns the value of attribute ga4_index_section_count.



4
5
6
# File 'lib/govuk_publishing_components/presenters/layout_footer_helper.rb', line 4

def ga4_index_section_count
  @ga4_index_section_count
end

Returns the value of attribute ga4_ogl_link_index_section.



4
5
6
# File 'lib/govuk_publishing_components/presenters/layout_footer_helper.rb', line 4

def ga4_ogl_link_index_section
  @ga4_ogl_link_index_section
end

Instance Method Details



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/govuk_publishing_components/presenters/layout_footer_helper.rb', line 22

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