Archived topic
Install Site Tracking Code
9 replies · Started by John on October 22, 2021
Hello GeneratePress Help !
It's been a while. Because everything is going so well with my site. Thank you !
I have signed up to ActiveCampaign. I want to enable site tracking. ActiveCampaign tells me that I need to install site tracking on my site. They provide a code which I am supposed to add to the footer of each page I want tracked. Well, I have far too many pages in order to do that manually.
Here is a link to their explanation: https://help.activecampaign.com/hc/en-us/articles/221493708-How-to-set-up-Site-Tracking#how-to-turn-on-site-tracking-and-whitelist-domains
Is there a way to add the site tracking code in one spot which will cover the entire site?
John Magee
Hi there,
A hook element:
https://docs.generatepress.com/article/hooks-element-overview/
With the wp_footer hook should be what you are looking for:
https://docs.generatepress.com/article/wp_footer/
Hope this helps.
That was fast, Leo. Thank you !
I'm not sure if I got it right with creating a hook, because this appeared after "Execute PHP":
"Unable to execute PHP as DISALLOW_FILE_EDIT is defined."
If that is a problem, would it help if I gave you access to my WP-site?
Here is the tracking code from ActiveCampaign that I am supposed to embed on all pages:
<script type="text/javascript">
(function(e,t,o,n,p,r,i){e.visitorGlobalObjectAlias=n;e[e.visitorGlobalObjectAlias]=e[e.visitorGlobalObjectAlias]||function(){(e[e.visitorGlobalObjectAlias].q=e[e.visitorGlobalObjectAlias].q||[]).push(arguments)};e[e.visitorGlobalObjectAlias].l=(new Date).getTime();r=t.createElement("script");r.src=o;r.async=true;i=t.getElementsByTagName("script")[0];i.parentNode.insertBefore(r,i)})(window,document,"https://diffuser-cdn.app-us1.com/diffuser/diffuser.js","vgo");
vgo('setAccount', '27184010');
vgo('setTrackByDefault', true);
vgo('process');
</script>
John
Hi John,
This article should be helpful:
https://docs.generatepress.com/article/disallow-php-execution/
Super fast and super helpful, Ying. Thank you.
But wait, did I understand the article that “Unable to execute PHP as DISALLOW_FILE_EDIT is defined.” is a good thing, because it is an extra layer of security?
John
You can only allow PHP execution in GP hooks using this snippet:
https://docs.generatepress.com/article/generate_hooks_execute_php/
But do I want to overwrite PHP as DISALLOW_FILE_EDIT?
John
Leo's snippet allows your site to execute PHP inside hook elements.
I think it's a better solution in your case.
Hi Ying,
Ok, I entered the snippet which Leo had recommended. And I think I did it correctly. Thank you !
John
No problem :)