Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Re: Unable to get collection_viewed customer event to fire

Unable to get collection_viewed customer event to fire

rshopshear
Shopify Partner
2 0 0

I have set up and subscribed to several events that work fine. I am trying now to get collection_viewed to work.

 

I can receive all of the checkout started, info submitted, etc. For context, when it fires, it will add a cookie, IP address ,etc. 

 

Following similar example:

 

analytics.subscribe("collection_viewed", event => {

 

const collection = event.data.collection;
const collectionTitle = collection.title;

track.view_collection({
_source: some source,
shop_name: 'shop name',
collection: collection title
});
});

 

Is there a way to tell if the event is firing or not?  I have tried this on accounts with Shopify Plus and without. The customer events work fine on either one. 

Replies 3 (3)

Liam
Community Manager
3108 344 889

Hi Rshopshear,

 

There are a few ways you can debug this event to see if it's firing or not. Here are a few methods you can use:

  1. Using the browser's console: You can use console.log statement to print out the event data. This will give you a clear idea about whether your event is firing or not. For example:
analytics.subscribe("collection_viewed", event => {
 .log(event);

  const collection = event.data.collection;
  const collectionTitle = collection;

  track.view_collection({
    _source: some source,
    shop_name: 'shop name',
    collection: collection title
  });
});
  1. Using the Network tab in developer tools: You can monitor the network requests in your browser's developer tools. If the event is firing, you should see a network request being sent to the server.

  2. Using a debugging tool: If you're using a tool like Google Tag Manager, they often have a debug mode that you can use to see if events are firing.

  3. Checking server logs: If you have to server logs, you can check if the event data is being received on the server side.

Remember, the collection_viewed event is available on the online store page and logs an instance where a buyer visited a product index page. Make sure you're correctly navigating to a collection page for the event to trigger.

 

Try out the above and let us know if you're still seeing an issue - hope this helps!

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

Not applicable
colarosa_
Tourist
4 0 1