Skip to content

Commit

Permalink
Add data-ga4-ecommerce-content-id to search results
Browse files Browse the repository at this point in the history
We want to track the content id of results, as the URLs get cut off by GA4s 100 character limit
  • Loading branch information
AshGDS committed Oct 20, 2023
1 parent 04f9d6d commit 700f35d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/presenters/search_result_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def structure_parts
def ga4_ecommerce_data(path)
{
ga4_ecommerce_path: path,
ga4_ecommerce_content_id: @document.content_id,
}
end

Expand Down
2 changes: 2 additions & 0 deletions spec/presenters/result_set_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
data_attributes: {
ecommerce_path: "/path/to/doc",
ga4_ecommerce_path: "/path/to/doc",
ga4_ecommerce_content_id: "content_id",
ecommerce_row: 1,
ecommerce_index: 1,
track_category: "navFinderLinkClicked",
Expand Down Expand Up @@ -203,6 +204,7 @@
description: "document_description",
data_attributes: {
ga4_ecommerce_path: "/path/to/doc",
ga4_ecommerce_content_id: "content_id",
},
},
metadata: {
Expand Down
2 changes: 2 additions & 0 deletions spec/presenters/search_result_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
description: "I am a document. I am full of words and that.",
data_attributes: {
ga4_ecommerce_path: link,
ga4_ecommerce_content_id: "content_id",
ecommerce_path: link,
ecommerce_row: 1,
ecommerce_index: 1,
Expand Down Expand Up @@ -108,6 +109,7 @@
description: "Part description",
data_attributes: {
ga4_ecommerce_path: "#{link}/part-path",
ga4_ecommerce_content_id: "content_id",
ecommerce_path: "#{link}/part-path",
ecommerce_row: 1,
ecommerce_index: 1,
Expand Down

0 comments on commit 700f35d

Please sign in to comment.