Assigning and ID to a html tag on the live website(for tracking purposes, etc)

Sometimes, for tracking purposes, it’s necessary to assign an ID to a specific HTML element on your website. However, IDs assigned from the Velo coding panel are not displayed in the source code of the live website. Therefore, a different approach is required.

One effective solution is to use custom code. This method has proven successful in most cases encountered so far.

To implement this, you will need to copy the element’s selector and then adjust the code below with the updated details:

<script>
window.onload = function() {
    // Get the element using its current selector
    var element = document.querySelector('#exampleSelector > h3');
    
    // Check if the element exists to avoid errors
    if (element) {
        // Assign a new ID to the element
        element.id = 'IDYouWIshToAssign';
    } else {
        console.log('Element not found');
    }
};
</script>