• Creation and evaluation of user-defined click events

    Table of contents

    In short

    Varify.io® does not collect any data itself. Nevertheless, you have the option of tracking elements that only appear in the variants of your A/B tests using your own web analytics system. Here we present the procedure with Google Analytics 4.

    Click tracking on an element in a variant

    Click tracking for newly added elements

    To record clicks on elements of your website, including those that were added by a variantyou can customize the following JavaScript according to your needs and easily integrate it into a variant of an experiment. Add the code using the "Add JS" function. 

    Make sure that if you have added further JS code that the code is placed at the end. In addition, the newly added, clickable elements should be given their own ID. Then adjust the value of myBtn in line 1 according to the ID you have assigned to the new element.

    				
    					//Replace myBtn with the ElementID of your new Element
    document.getElementById("myBtn").addEventListener("click", VarifyTrack);
    function VarifyTrack() {
        gtag('event', 'VarifyClick', {
            'VarifyClick': '1',
            'revenue': '1',
            'example': 'testing'
        });
    }
    				
    			

    Click tracking for existing elements

    With Varify.io you can send click events from any element of your website directly to Google Analytics. Simply adjust the following code according to your needs. It is crucial that you insert the correct CSS selector in line 2 of the code. To do this, replace the placeholder .test123 with the desired CSS selector. Add the code using the "Add JS" function. 

    To identify the appropriate selector, select the element in the Varify editor. The CSS class of the element is then displayed above. Note: It can happen that several elements on a page have the same class. If you want to track a specific element, it is advisable to enter an ID (prefixed with #) to be used.

    				
    					// Ersetze .test12 mit dem Query-Selektor deines Elements
    document.querySelector(".test123").addEventListener("click", VarifyTrack);
    
    function VarifyTrack() {
        gtag('event', 'VarifyClick', {
            'VarifyClick': '1',
            'revenue': '1',
            'example': 'testing'
        });
    }
    
    				
    			

    Evaluation of user-defined click events in GA4

    So that you can now also evaluate the click events created in the results of your A/B tests, you now create custom metrics in Google Analytics according to the events. You can then import custom metrics in the exploratory data analysis in GA4 under Metrics. 

    We have created a separate article for you: Evaluate custom events in explorative reports.

    We generally recommend using Custom Metrics instead of Custom Conversions, as Custom Metrics, in contrast to Custom Conversions much better for individual evaluation are. 

  • First steps

    Tracking & Evaluation

    Targeting

    Advanced

    Function overview