2

Google Analytics considers a file download a link to one of their supported file types. But my single page app generates files on the fly and then generates a hyperlink with base64 data and prompts the user to download it. I want to capture that event as a Conversion as far as analytics is concerned. After my file download code, I'm sending

gtag('event', 'file_download', {'send-to':'downloads'});

I see the event being posted in the console and google reports a 204 No Content status back, so everything is working at the network level. But I am not seeing any events listed under Events > events or Engagement > events or even Dashboard > top events. What could be going wrong?

1
  • I'd be careful using 'send-to'. GA4 does not allow you to define dimensions with a '-' in them, and it is very close to 'send_to' which is reserved and controls what property receives the event. Otherwise it looks like it should work. Try using the GA4 DebugView to see if it is received. – Tony McCreath Mar 22 at 21:59
2

https://developers.google.com/analytics/devguides/collection/gtagjs/events shows how to do it. The general case from there is:

gtag('event', 'aaa', {
  'event_category' : 'bbb',
  'event_label' : 'ccc'
});

You are not setting the event_category or the event_label. All you are sending is the send-to data which Google Analytics will ignore because it doesn't know how to deal with it. You need to send the event like:

gtag('event', 'file_download', {
  'event_category' : 'send-to',
  'event_label' : 'downloads'
});
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.