1FP.fns.ga4_set_g_ids = function(nr, type, ID) { 2 3 let ga_ids = FP.readCookie('fp_ga_ids'); 4 5 if ( ga_ids ) { 6 ga_ids = JSON.parse( ga_ids ); 7 } else { 8 ga_ids = {}; 9 } 10 11 ga_ids['ga4' + nr + '_' + type] = ID; 12 13 FP.setCookie( 'fp_ga_ids', JSON.stringify(ga_ids) ); 14} 15 16function fupi_load_gads(){ 17 18 if ( ! fp.loaded.includes('ga41') || fp.ga41.id != fp.gads.id ) { 19 if ( fp.vars.gtag_enh_conv ) { 20 window.gtag( 'config', fp.gads.id, { 'allow_enhanced_conversions': true } ); 21 } else { 22 window.gtag( 'config', fp.gads.id ); 23 } 24 } 25 26 27 28 FP.loaded('gads_config', 'gads'); 29}; 30 31function fupi_load_ga4( nr ) { 32 33 var _ga = fp[ 'ga4' + nr ], 34 params = {}; 35 36 if ( fp?.gads?.id && fp?.gads?.id == fp.ga41.id && fp.vars.gtag_enh_conv ) { 37 params.allow_enhanced_conversions = true; 38 } 39 40 // CHANGE COOKIE PREFIX 41 // optional for the tracking ID #1 42 if ( _ga.cookie_prefix && nr == '1' ) params.cookie_prefix = '_fp4' + nr; 43 44 // enable GA's debug mode 45 // @ https://support.google.com/analytics/answer/7201382?hl=en 46 if ( fpdata?.cookies?.ga4_debug ) params.debug_mode = true; 47 48 49 50 // SEND CLEAN "PAGE TITLE" 51 if ( _ga.clean_page_title && fpdata.page_title && fpdata.page_title.length > 0 ) { 52 params.page_title = fpdata.page_title; 53 54 // "SEO TITLE" CUSTOM DIMENSION 55 if ( _ga.seo_title ) { 56 params.seo_title = document.title; 57 } 58 } 59 60 // "PAGE LANGUAGE" CUSTOM DIMENSION 61 if ( _ga.page_lang ) { 62 params[_ga.page_lang] = document.documentElement.lang || 'undefined'; 63 } 64 65 // "PAGE TYPE" CONTENT GROUPING 66 if ( _ga.page_type && fpdata.page_type && fpdata.page_type.length > 1 ) { 67 params[_ga.page_type] = fpdata.page_type; 68 } 69 70 // "PAGE ID" CUSTOM DIMENSION 71 if ( _ga.page_id && fpdata.page_id && fpdata.page_id > 0 ) { 72 params[_ga.page_id] = '' + fpdata.page_id; 73 } 74 75 // "PAGE NUMBER" CUSTOM DIMENSION 76 if ( _ga.page_number && fpdata.page_number > 0 ) { 77 params[_ga.page_number] = '' + fpdata.page_number; 78 } 79 80 // "AUTHOR DISPLAY NAME" CUSTOM DIMENSION 81 if ( _ga.post_author && fpdata.author_name && fpdata.author_name.length > 0 ) { 82 params[_ga.post_author] = fpdata.author_name; 83 } 84 85 // "AUTHOR ID" CUSTOM DIMENSION 86 if ( _ga.author_id && fpdata.author_id > 0 ) { 87 params[_ga.author_id] = '' + fpdata.author_id; 88 } 89 90 // "PUBLISHED DATE" CUSTOM DIMENSION 91 if ( _ga.post_date && fpdata.published && fpdata.published.length > 0 ) { 92 params[_ga.post_date] = fpdata.published; 93 } 94 95 96 97 // "SEARCH RESULTS" CUSTOM METRIC 98 if ( _ga.search_results_nr && _ga.search_results_nr.length > 0 && fpdata.search_results && fpdata.search_results > 0 ) { 99 params[_ga.search_results_nr] = parseInt(fpdata.search_results); 100 } 101 102 // "USER ROLE" USER PROPERTY 103 if ( _ga.user_role ) { 104 if ( fpdata.user.role && fpdata.user.role.length > 0 ) { 105 params[_ga.user_role] = fpdata.user.role; 106 } 107 } 108 109 // "TAXONOMY TERMS" CUSTOM DIMENSION 110 if ( _ga.tax_terms && fpdata.terms && fpdata.terms.length > 0 ) { 111 112 var term_arr = fpdata.terms.map( function (term_data) { 113 var term = _ga.send_tax_terms_titles ? term_data.name : term_data.slug; 114 term += _ga.add_tax_term_cat ? ' (' + term_data.taxonomy + ')' : ''; 115 return term; 116 } ); 117 118 params[_ga.tax_terms] = term_arr.join(', '); 119 } 120 121 window.gtag( 'config', _ga.id, params ); 122 123 124 125 FP.loaded('ga4' + nr + '_config', 'ga4' + nr ); 126} 127 128function fupi_enable_gtag() { 129 130 // First, fix GAds IDs 131 if ( fp.gads ) { 132 if ( 133 fp.gads.id && 134 ! fp.gads.id.includes('AW-') && 135 ! fp.gads.id.includes('GT-') && 136 ! fp.gads.id.includes('G-') 137 ) fp.gads.id = 'AW-' + fp.gads.id; 138 139 if ( 140 fp.gads.id2 && 141 ! fp.gads.id2.includes('AW-') && 142 ! fp.gads.id2.includes('GT-') && 143 ! fp.gads.id2.includes('G-') 144 ) fp.gads.id2 = 'AW-' + fp.gads.id2; 145 } 146 147 // set gtag date 148 if ( ! fp.loaded.includes('gtg') ) { 149 window.gtag('js', new Date()); 150 } 151 152 fp.vars.gtag_enh_conv = false; 153 154 155 156 FP.loaded('gtag_config', 'gtg'); 157}; 158 159function fupi_load_ga41(){ 160 fupi_load_ga4( 1 ); 161}; 162 163function fupi_load_ga42(){ 164 fupi_load_ga4( 2 ); 165}; 166 167FP.load('gtag_config', 'fupi_enable_gtag', ['head_helpers', 'gtag_file']); 168 169if ( fp.ga41?.id ) { 170 FP.load('ga41_config', 'fupi_load_ga41', ['gtag_config']); 171 172} 173 174if ( fp.gads?.id ) FP.load('gads_config', 'fupi_load_gads', ['gtag_config']);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.