php only works when i’m logged into wordpress.
-
Hi all,
I’ll start out by saying i’m not a used to php or word press dev. I’m a .net developer.My company has a php site on wordpress that i’m trying to add google tracking to.
There is a single header.php file for all pages so i’ve added a little piece of php to check what the current page is and to write out the appropriate event trigger.Now, on the live site, when i’m logged into word-press and run the page, I can see the triggers firing fine on Tag assistant, if i un-comment the alerts, they also fire.
When i log out of word-press and hit the page, nothing happens at all. No alerts, no google triggers, nothing in the php is running?
Any ideas whats going on ?
<script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'AW-1234567897'); <?php $url = $_SERVER['REQUEST_URI']; if ($url =="/thankyou/") { print " gtag('event', 'conversion', {'send_to': 'AW-1234567897/1234567897', 'value': 1.0, 'currency': 'GBP' }); "; print " gtag('event', 'conversion', {'send_to': 'AW-1234567897/1234567897'}); "; //Print "alert('OK');"; //Print "alert('" . $url . "');"; } ?> </script>
tia
Dave
- The topic ‘php only works when i’m logged into wordpress.’ is closed to new replies.