Skip to content

Instantly share code, notes, and snippets.

@MrSwed
Created January 23, 2020 17:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MrSwed/9d499a330c641f630806e9e7c0c41645 to your computer and use it in GitHub Desktop.
Save MrSwed/9d499a330c641f630806e9e7c0c41645 to your computer and use it in GitHub Desktop.
WordPress NinjaForm Yandex metric Targeting
(function($){
// Setup Ninja form - on Sumbit Yandex metric targeting.
$(document).on('nfFormSubmitResponse', function(e, r){
var Target = "form-"+r.id,
YMVar = $(document.scripts).filter(function(){ return /w.yaCounter\d+/.test($(this).text()) }).text().replace(/^.*w.(yaCounter\d+)\s+.*$/im, "$1");
if (YMVar && window[YMVar]) window[YMVar].reachGoal(Target);
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment