Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion assets/src/js/integrations/form-submit.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ document.addEventListener('DOMContentLoaded', () => {
* Send a custom event to Plausible.
*/
trackSubmission: function () {
plausible(plausible_analytics_i18n.form_completions, {'props': {'path': document.location.pathname}});
plausible(plausible_analytics_i18n.form_completions);
}
};

Expand Down
2 changes: 1 addition & 1 deletion assets/src/js/integrations/form-submit.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 1 addition & 14 deletions src/Actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,9 @@ public function maybe_register_assets() {

// Track 404 pages (if enabled)
if ( Helpers::is_enhanced_measurement_enabled( '404' ) && is_404() ) {
$data = wp_json_encode(
[
'props' => [
'path' => 'document.location.pathname',
],
]
);

/**
* document.location.pathname is a variable. @see wp_json_encode() doesn't allow passing variable, only strings. This fixes that.
*/
$data = str_replace( '"document.location.pathname"', 'document.location.pathname', $data );

wp_add_inline_script(
'plausible-analytics',
"document.addEventListener('DOMContentLoaded', function () { plausible( '404', $data ); });"
"document.addEventListener('DOMContentLoaded', function () { plausible( '404' ) });"
);
}

Expand Down