When doing autocapture through gtm, can i specify the type of events i want to capture?
In Mixpanel Autocapture, extra attributes refer to additional HTML attributes that you can specify to be captured along with the default set of properties on autocaptured events. By default, Autocapture collects a limited set of HTML attributes (such as class
, name
, aria-label
, role
, title
, and type
) to help describe the elements users interact with, while avoiding sensitive data.If you want to capture more specific attributes (for example, custom data attributes like data-cta-name
or data-cta-position
), you can use the capture_extra_attrs
option in your Autocapture configuration. This allows you to include these extra attributes in the event data sent to Mixpanel.**Example configuration:**LBKSmixpanel.init('YOUR_PROJECT_TOKEN', { autocapture: { click: true, capture_extra_attrs: ['data-cta-name', 'data-cta-position'] } });LBKS
With this setup, whenever an autocaptured event (like a click) occurs, Mixpanel will also collect the values of the specified extra attributes from the target element, if they exist.This feature is especially useful for tracking custom metadata on elements that are important for your analysis, without having to manually instrument those events.For more details, see the documentation: Mixpanel SDKs: Javascript – Autocapture and GTM with custom Autocapture initialization options.
kapa.ai is still learning and improving, please let me know how I did by reacting below.
ℹ️ Tip: Mention @kapa.ai in the thread for follow-ups or DM the app for 1-to-1 help.
Let me check the knowledge base for you again. One moment! 📚
Based on the knowledge sources, specifying the types of events to capture with Mixpanel Autocapture through Google Tag Manager (GTM) requires the use of a Custom JavaScript variable. The standard GTM template interface only provides a simple enabled/disabled toggle for Autocapture. To customize which event types (like clicks, pageviews, scrolls, etc.) are captured, you must define a custom configuration object via a Custom JavaScript variable and use that in your Mixpanel tag setup in GTM.There is no mention in the documentation of a way to specify event types for Autocapture in GTM without using custom JavaScript. The only way to go beyond the default on/off toggle is through this method Initialization – GTM with custom Autocapture initialization options.
kapa.ai is still learning and improving, please let me know how I did by reacting below.
ℹ️ Tip: Mention @kapa.ai in the thread for follow-ups or DM the app for 1-to-1 help.
Let me check the knowledge base for you again. One moment! 📚
Yes, when using Mixpanel Autocapture through Google Tag Manager (GTM), you can specify the types of events you want to capture by customizing the autocapture configuration. This is done by creating a Custom JavaScript variable in GTM that returns your desired autocapture configuration object. For example, you can choose to enable or disable capturing of pageviews, clicks, inputs, scrolls, submits, and more.Here’s how you can do it: 1. Create a Custom JavaScript Variable in GTM that returns the autocapture configuration object with your preferred event types. For example:
return {
pageview: "full-url",
click: true,
input: false, // disables input event capture
scroll: true,
submit: false, // disables form submit event capture
capture_extra_attrs: ['data-cta-name', 'data-cta-position']
};
}
```LBKSLBKS2. **Use this variable in your Mixpanel initialization tag** in GTM. Instead of selecting “Enabled” or “Disabled” for Autocapture, select your custom JavaScript variable.LBKSThis approach allows you to control exactly which event types are captured by Autocapture via GTM, rather than using the default settings or a simple on/off toggle. You can verify your setup using GTM’s preview mode and by checking the captured events in Mixpanel.LBKSFor more details, see the official documentation: [GTM with custom Autocapture initialization options](https://docs.mixpanel.com/docs/tracking-methods/integrations/google-tag-manager#initialization).
kapa.ai is still learning and improving, please let me know how I did by reacting below.
ℹ️ Tip: Mention @kapa.ai in the thread for follow-ups or DM the app for 1-to-1 help.
Hi Chris S., Please stand by as I search the Mixpanel knowledge base for an AI-powered answer. I normally take about 15 seconds or so. In case AI cannot answer your question, feel free to reach out to Mixpanel support at mixpanel.com/get-support. If you have follow-up questions for this thread, please tag me again with your question: @kapa.ai <follow-up question> 👋
Feel free to ask a follow-up question once I've answered by mentioning me with @kapa.ai