Skip to content
Open
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
14 changes: 9 additions & 5 deletions admin/godam-transcoder-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -626,11 +626,15 @@ function rtgodam_get_localize_array() {

$localize_array = array();

$localize_array['endpoint'] = RTGODAM_ANALYTICS_BASE;
$localize_array['isPost'] = empty( is_single() ) ? 0 : is_single();
$localize_array['isPage'] = empty( is_page() ) ? 0 : is_page();
$localize_array['isArchive'] = empty( is_archive() ) ? 0 : is_archive();
$localize_array['postTitle'] = get_the_title();
$localize_array['endpoint'] = RTGODAM_ANALYTICS_BASE;
$localize_array['isPost'] = empty( is_single() ) ? 0 : is_single();
$localize_array['isPage'] = empty( is_page() ) ? 0 : is_page();
$localize_array['isArchive'] = empty( is_archive() ) ? 0 : is_archive();
Comment on lines +629 to +632
// Resolve the title from the queried object, not the global $post: this runs
// on wp_enqueue_scripts, where the loop global can hold an unrelated post
// (first post on archives, or one left behind by a secondary query). Empty
// on non-singular pages — there is no single post to attribute the view to.
$localize_array['postTitle'] = is_singular() ? get_the_title( get_queried_object_id() ) : '';
$localize_array['locationIP'] = rtgodam_get_user_ip();

/**
Expand Down
6 changes: 5 additions & 1 deletion assets/src/js/godam-player/analytics-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,11 @@ export function buildAnalyticsRequestBody( {
email: emailId || '',
visitor_timestamp: visitorTimestamp || Date.now(),
visit_entry_action_url: window.location.href,
visit_entry_action_name: document.title,
// Prefer the WP-resolved post title: document.title is the SEO/document
// title ("Post – Site Name", or whatever an SEO plugin emits), not the
// post title. PHP localizes postTitle only on singular pages; elsewhere
// document.title is the best page name available.
visit_entry_action_name: postTitle || document.title,
referer_type: '',
referer_name: document.referrer || '',
referer_url: document.referrer || '',
Expand Down
Loading