Mixpanel Community Icon

How does JQL work on mixpanel

·
·

How does JQL work on mixpanel

  • Avatar of kapa.ai
    kapa.ai
    APP
    ·
    ·

    Hi Arshan K., 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

  • Avatar of kapa.ai
    kapa.ai
    APP
    ·
    ·

    JQL (JavaScript Query Language) is a feature of Mixpanel that allows you to run arbitrary queries on your Mixpanel events. However, it's important to note that Mixpanel is not investing in JQL any further and recommends using the Data Pipelines add-on to export your events to your data warehouse source.In JQL, the JavaScript code must define a main() function. This JavaScript will be compiled, and the main() function will be executed by the query engine. The return value of main() must be a sequence of zero or more transformations applied to a collection of events, user records, or joined records. Events are retrieved by calling the Events() function.Here's an example of a JQL query that counts the number of events that happened on a specific day: javascript function main() { return Events({ from_date: "2016-01-04", to_date: "2016-01-04" }).reduce(mixpanel.reducer.count()); }LBKSYou can also query events by calling Events() with a single object argument that describes what events should be fetched. For example: javascript function main() { // Get all signups and purchases by users with email addresses // from Yahoo or Gmail between January 1st and January 2nd return Events({ from_date: '2016-01-01', to_date: '2016-01-02', event_selectors: [ {event: 'signup', label: 'Signup'}, {event: 'purchase', selector: '"yahoo" in properties["$email"]', label: 'Purchase (Yahoo)'}, {event: 'purchase', selector: '"gmail" in properties["$email"]', label: 'Purchase (Gmail)'} ] }) }LBKSYou can also use the Mixpanel-utils module to query the JQL API in Python: python script = ''' function main() { return Events({ from_date: '2016-11-30', to_date: '2016-12-01' }) .groupBy(["name"], mixpanel.reducer.count()); }''' mputils.query_jql(script)LBKSThis function will return the JSON response of the JQL query as a Python dictionary source.You can also use the HTTP API to use JQL. You write a script and post it to an API endpoint with some authentication parameters. Note that the Query API has a rate limit of 60 queries per hour and a maximum of 5 concurrent queries source.Please note that JQL features are only available in the 'All Project Data' Data View source.

    kapa.ai is still learning and improving, please let me know how I did by reacting below

    ⤵️ Hint: Mention @kapa.ai in the thread for follow-ups.