alphagov / govuk_frontend_toolkit

❗️GOV.UK Frontend Toolkit is deprecated, and will only receive major bug fixes and security patches.
MIT License
403 stars 107 forks source link

Unable to implement custom trackEvent #474

Closed RyanMacG closed 4 years ago

RyanMacG commented 5 years ago

We're trying to implement a custom tracker on the Trade Tariff frontend to record interactions with the regulatory links. I've tried following the documentation resulting in;

Frontend

  <td class="numerical">
    <% if !measure.national? && measure.legal_acts.present? %>
      <%= link_to measure.legal_acts.first.regulation_code, "##{measure.id}-regulations", class: 'reference', 'data-popup-ref' => "#{measure.id}-regulations", 'data-tracker-name' => 'legal-acts' %>
    <% end %>
  </td>

JS

  // Track lebal base interaction
  GOVUK.analytics.trackEvent('Legal base', 'click', { 'trackerName': 'legal-acts' })

but when I check the console I receive the following error from the analytics debugger;

analytics_debug.js:24 Invalid command: [object Arguments]
log @ analytics_debug.js:24
O @ analytics_debug.js:23
se @ analytics_debug.js:87
jf.N @ analytics_debug.js:95
jf.H @ analytics_debug.js:94
Z.P @ analytics_debug.js:101
cd @ analytics_debug.js:87
A @ analytics_debug.js:87
(anonymous) @ analytics_debug.js:104
(anonymous) @ analytics_debug.js:104
analytics_debug.js:24 Command is not an array or function: "abort"

Any advice on how to properly implement this would be appreciated as I can't spot the issue.

NickColley commented 4 years ago

Hey Ryan,

Following the deprecation of this library this analytics code has been removed in version 9.0.0.

Sorry for the delay responding to this, I recommend moving away from this code as it I no longer maintained by anyone.

Going to close this out as I'm not sure I can help with this issue with this in mind, thanks for your patience.

Nick