I have i one template file call abc.php and using this template only for 1 page now i want to add google conversion tracking code in section. If i add code before get_header(); function then it shows before tag and if i put after get_header(); then it shows in tag.
Please help me as i want to use conversion code only for 1 particular page so i can’t add this code in header.php
<?php
/* Template Name: Cost_Estimation_Result */
?>
<!-- Event snippet for Website lead conversion page -->
<script>
gtag('event', 'conversion', {'send_to': '*********************'});
</script>
<?php
get_header();
?>
2
Answers
Add Below code in function.php solved my problem.
Add this javascript
try this not sure if it will work though , another way if u get string from get_header() and append gtag part before loading in your page like this :
reference https://stackoverflow.com/a/18187111/8719734