Analytics Tools

Error when creating an event with the event Chrome extension

Last updated: October 13, 2020

Applies to:

Marketing Hub  Enterprise

When you create an event using the event Chrome extension, you may encounter the following error message: This selector is longer than 280 characters. Try selecting a different element or putting an ID closer to the element you'd like to attach this event to.

The event Chrome extension determines a jQuery selector from the element's code to create events. This error occurs when an element has the same selector as another on the page that is already associated with an event.

For example, multiple bulleted lists within the same <div> tag have this issue.

Duplicate bulleted items

In this example, the extension cannot distinguish the selector for the bulleted item in list 1 ("For spelling out benefits and") from the bulleted item in list 2 ("Search our user guides").

Both elements are found to have the same jQuery selector: 

span#hs_cos_wrapper_right_column.hs_cos_wrapper.hs_cos_wrapper_widget.hs_cos_wrapper_type_rich_text > ul > li:eq(1)

For these types of similar elements, it's recommended to manually add an id tag to the elements to ensure that the extension is able to find a unique identifier:

  • Navigate to the HTML or source code of your page.
  • Search for the elements that are causing the extension error and add: id="unique_id" to each item.
Add id tags to HTML
Add id tags to HTML

Once the unique ID tags are added and the page is updated, the extension can be used to create your events as they will pull a unique jQuery selector.

Unique id for bulleted item 2