Skip to content

Instantly share code, notes, and snippets.

@kolbaba
Created January 30, 2020 21:28
Show Gist options
  • Save kolbaba/dfd8bc62eff5f8cc94c6a9a01a9419e4 to your computer and use it in GitHub Desktop.
Save kolbaba/dfd8bc62eff5f8cc94c6a9a01a9419e4 to your computer and use it in GitHub Desktop.
pnt

PNT

SEE DOC https://gist.github.com/kolbaba/5c9b112ffc3db9e4b3648eae8b655f11

Modern Method for Adding PNT

<script>
    document.querySelectorAll('form')[0].classList.add('pnt')
</script>

<script>
    document.getElementById('form').classList.add('pnt')
</script>

<script>
    document.getElementsByClassName('form')[0].classList.add('pnt')
</script>

<script>
    document.getElementsByTagName("element")[0].classList.add('pnt');
</script>

<script>
    document.getElementById('form_id').classList.add('pnt')
</script>

<script>
    document.querySelector('firstElement')[0].classList.add('pnt')
</script>

<script>
    document.querySelectorAll('allElementsOfType')[0].classList.add('pnt')
</script>

<script>
    document.querySelectorAll('form')[3].classList.add('pnt')
</script>

Hit all elements of

<script>
var forms = document.querySelectorAll('form')
for (var i = 0; i < forms.length; i++) {
  forms[i].classList.add('pnt')
}
</script> 


definitions

selector: [‘.form-class’]

This is used when you're trying to target a form to add pnt. Use this when other methods of adding pnt are not working.

leads.pollForForm(‘.late-form’) This is used when the form is not sending data or tracking is not working. You need to target the form's id or class for this to work. Think of this as a loop.

leads.submitOn(‘click’, ‘a.link-submit’) Use this when form-inquiry isn't being passed or if the submit button is not a standard one. Simply target the submit button, replace a.link-submit to class or id of submit button.

ignoreFields If you want to ignore fields such as password or other personal information

Form Tracking Testing

Open incognito browser Open dev pane > network tab > check preserve log Visit page > Network tab > see 2x “visit” entries Go to page with form Application tab > Local storage > site.com Type into forms and notice lead_ keys show up with your data in value column Go back to network tab > submit form > see 2x “form-inquiry” go through

Testing GA Event Tracking

Example: https://www.illinoissafety.com/ Setup tracking for “SIGN UP” link in NAV and content When clicked submit event

To test this:

(Testing in Firefox right now) Load the page and open devpane Target the link in the inspector pane Open network pane Click the link See "200 - collect?v=...." Click the collect file and see in the right pane “Params” (Based on the category/action/ etc…): T: event ec: “Sign Up Via Click” Ea: Sign up for class


OLD WAYS:

Forms of PNT

$( "form" ).addClass( "pnt" );
jQuery( "form" ).addClass( "pnt" );
pntjQuery( "form" ).addClass( "pnt" );
document.getElementsByClassName('form')[0].classList.add('pnt');

jQuery Loop Version 1

<script>
jQuery(function(){
    (function loop() {
        setTimeout(function () {
            var f = jQuery('form');
            if (f[0]) {
                f.addClass('pnt');
                
            } else {
                loop();
            }
        }, 250);
    }());
});
</script>

jQuery Loop Version 2

<script>
$(function() {
    var loop = setInterval(function () {
            var $form = $('form')
        if ($form.length) {
            $form.addClass('pnt')
            clearInterval(loop)
        }
    }, 250);
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment