I'm calling the permalink of post on submitting a form like below:
var $this = $(this),
category = $this.attr('data-event-category'),
action = $this.attr('data-event-action'),
label = $this.attr('data-event-label')
permalink = call_url["permalink"]
self.track(category, action, permalink);
console.log('tracking pushed: '+category+', '+action+', '+permalink+','+label)
});
},
Which I'm calling via my functions.php
wp_register_script( 'analytics', get_template_directory_uri() . '/js/analytics.js','','1.0.1');
wp_enqueue_script( 'analytics' );
wp_localize_script(
"analytics"
, "call_url"
, [
"permalink" => get_permalink($post),
]
);
All works great and appear in my console fine.
Only thing is, I would like it to the permalink to appear as an data-attribute like the category, action and label.
For that I tried the below:
permalink = $this.attr('call_url["permalink"]')
Which doesn't seems t work.
Any help will be super ??
Thank you !