-
AuthorPosts
-
March 12, 2019 at 2:19 pm #1077831
I need to add a few tracking scripts to the site, using this just does not work (copied, pasted and edited)
gives error when code and name is added
Your PHP code changes were rolled back due to an error on line 753 of file wp-content/themes/enfold/functions.php. Please fix and try saving again.
syntax error, unexpected ‘)’, expecting ‘&’ or variable (T_VARIABLE)March 14, 2019 at 5:08 am #1078515Hey Gilesamc,
Then there’s something wrong with your code, please check it carefully. If you need help then post it here.
Best regards,
RikardMarch 14, 2019 at 11:18 am #1078642got 1 script to load on its own but when i add the next 2 I get the error
Your PHP code changes were rolled back due to an error on line 786 of file wp-content/themes/enfold/functions.php. Please fix and try saving again.
Cannot redeclare custom_script_name() (previously declared in wp-content/themes/enfold/functions.php:758)
line 758 is
<?php
from the first script Bingcode I am trying to add is
function custom_script_name(){
?>
<script>(function(w,d,t,r,u){var f,n,i;w[u]=w[u]||[],f=function(){var o={ti:”5038044″};o.q=w[u],w[u]=new UET(o),w[u].push(“pageLoad”)},n=d.createElement(t),n.src=r,n.async=1,n.onload=n.onreadystatechange=function(){var s=this.readyState;s&&s!==”loaded”&&s!==”complete”||(f(),n.onload=n.onreadystatechange=null)},i=d.getElementsByTagName(t)[0],i.parentNode.insertBefore(n,i)})(window,document,”script”,”//bat.bing.com/bat.js”,”uetq”);</script><noscript></noscript>
<?php
}
add_action(‘wp_head’, ‘Bing’);function custom_script_name(){
?>
<script type=”text/javascript”>
adroll_adv_id = “2JXDUP7BRZDE7D26B7C32Y”;
adroll_pix_id = “23OQFE4GSRCZHKT7WTPNHL”;
/* OPTIONAL: provide email to improve user identification */
/* adroll_email = ” (Email address hidden if logged out) “; */
(function () {
var _onload = function(){
if (document.readyState && !/loaded|complete/.test(document.readyState)){setTimeout(_onload, 10);return}
if (!window.__adroll_loaded){__adroll_loaded=true;setTimeout(_onload, 50);return}
var scr = document.createElement(“script”);
var host = ((“https:” == document.location.protocol) ? “https://s.adroll.com” : “http://a.adroll.com”);
scr.setAttribute(‘async’, ‘true’);
scr.type = “text/javascript”;
scr.src = host + “/j/roundtrip.js”;
((document.getElementsByTagName(‘head’) || [null])[0] ||
document.getElementsByTagName(‘script’)[0].parentNode).appendChild(scr);
};
if (window.addEventListener) {window.addEventListener(‘load’, _onload, false);}
else {window.attachEvent(‘onload’, _onload)}
}());
</script>
<?php
}
add_action(‘wp_head’, ‘Adroll’);function custom_script_name(){
?>
<script type=”text/javascript”>
var _paq = _paq || [];
_paq.push([“trackPageView”]);
_paq.push([“enableLinkTracking”]);
(function () {
var u=((“https:” == document.location.protocol) ? “https” : “http”) + “://www.tag4arm.com/tags4arm/”;
_paq.push([“setTrackerUrl”, u + “tag4arm.php”]);
_paq.push([“setSiteId”, “33”]);
var d = document, g = d.createElement(“script”), s = d.getElementsByTagName(“script”)[0]; g.type = “text/javascript”;
g.defer = true; g.async = true; g.src = u + “tag4arm.js”; s.parentNode.insertBefore(g, s);
})();
</script>
<?php
}
add_action(‘wp_head’, ‘Tag4Arm’);March 14, 2019 at 11:21 am #1078643I have also noticed that even when I add just the bibg script though the edit is successfully added the script DOES NOT APPEAR IN THE HEAD so this is just NOT WORKING
March 14, 2019 at 11:27 am #1078645it does accept this but still DOESN”T ADD ANYTHING TO THE HEAD
//——————————-
// Custom script in head section
//——————————-function custom_script_name(){
?>
<script>(function(w,d,t,r,u){var f,n,i;w[u]=w[u]||[],f=function(){var o={ti:”5038044″};o.q=w[u],w[u]=new UET(o),w[u].push(“pageLoad”)},n=d.createElement(t),n.src=r,n.async=1,n.onload=n.onreadystatechange=function(){var s=this.readyState;s&&s!==”loaded”&&s!==”complete”||(f(),n.onload=n.onreadystatechange=null)},i=d.getElementsByTagName(t)[0],i.parentNode.insertBefore(n,i)})(window,document,”script”,”//bat.bing.com/bat.js”,”uetq”);</script><noscript></noscript>
<script type=”text/javascript”>
var _paq = _paq || [];
_paq.push([“trackPageView”]);
_paq.push([“enableLinkTracking”]);
(function () {
var u=((“https:” == document.location.protocol) ? “https” : “http”) + “://www.tag4arm.com/tags4arm/”;
_paq.push([“setTrackerUrl”, u + “tag4arm.php”]);
_paq.push([“setSiteId”, “33”]);
var d = document, g = d.createElement(“script”), s = d.getElementsByTagName(“script”)[0]; g.type = “text/javascript”;
g.defer = true; g.async = true; g.src = u + “tag4arm.js”; s.parentNode.insertBefore(g, s);
})();
</script>
<script type=”text/javascript”>
adroll_adv_id = “2JXDUP7BRZDE7D26B7C32Y”;
adroll_pix_id = “23OQFE4GSRCZHKT7WTPNHL”;
/* OPTIONAL: provide email to improve user identification */
/* adroll_email = ” (Email address hidden if logged out) “; */
(function () {
var _onload = function(){
if (document.readyState && !/loaded|complete/.test(document.readyState)){setTimeout(_onload, 10);return}
if (!window.__adroll_loaded){__adroll_loaded=true;setTimeout(_onload, 50);return}
var scr = document.createElement(“script”);
var host = ((“https:” == document.location.protocol) ? “https://s.adroll.com” : “http://a.adroll.com”);
scr.setAttribute(‘async’, ‘true’);
scr.type = “text/javascript”;
scr.src = host + “/j/roundtrip.js”;
((document.getElementsByTagName(‘head’) || [null])[0] ||
document.getElementsByTagName(‘script’)[0].parentNode).appendChild(scr);
};
if (window.addEventListener) {window.addEventListener(‘load’, _onload, false);}
else {window.attachEvent(‘onload’, _onload)}
}());
</script>
<?php
}
add_action(‘wp_head’, ‘analyise’);March 16, 2019 at 7:07 am #1079366Hi,
Thanks for the update, the problem is exactly what it says; you can’t redeclare the same function name: custom_script_name. Please pick unique names for your functions and try again.
Best regards,
RikardMarch 18, 2019 at 11:14 am #1079822so I added this and still nothing it saves it but the scripts are not in the pages
//——————————-
// Custom script in head section
//——————————-function bing(){
?>
<script>(function(w,d,t,r,u){var f,n,i;w[u]=w[u]||[],f=function(){var o={ti:”5038044″};o.q=w[u],w[u]=new UET(o),w[u].push(“pageLoad”)},n=d.createElement(t),n.src=r,n.async=1,n.onload=n.onreadystatechange=function(){var s=this.readyState;s&&s!==”loaded”&&s!==”complete”||(f(),n.onload=n.onreadystatechange=null)},i=d.getElementsByTagName(t)[0],i.parentNode.insertBefore(n,i)})(window,document,”script”,”//bat.bing.com/bat.js”,”uetq”);</script><noscript></noscript>
<?php
}
add_action(‘wp_head’, ‘bing’);function adroll(){
?>
<script type=”text/javascript”>
adroll_adv_id = “2JXDUP7BRZDE7D26B7C32Y”;
adroll_pix_id = “23OQFE4GSRCZHKT7WTPNHL”;
/* OPTIONAL: provide email to improve user identification */
/* adroll_email = “ (Email address hidden if logged out) “; */
(function () {
var _onload = function(){
if (document.readyState && !/loaded|complete/.test(document.readyState)){setTimeout(_onload, 10);return}
if (!window.__adroll_loaded){__adroll_loaded=true;setTimeout(_onload, 50);return}
var scr = document.createElement(“script”);
var host = ((“https:” == document.location.protocol) ? “https://s.adroll.com” : “http://a.adroll.com”);
scr.setAttribute(‘async’, ‘true’);
scr.type = “text/javascript”;
scr.src = host + “/j/roundtrip.js”;
((document.getElementsByTagName(‘head’) || [null])[0] ||
document.getElementsByTagName(‘script’)[0].parentNode).appendChild(scr);
};
if (window.addEventListener) {window.addEventListener(‘load’, _onload, false);}
else {window.attachEvent(‘onload’, _onload)}
}());
</script>
<?php
}
add_action(‘wp_head’, ‘adroll’);function tag4arm(){
?>
<script type=”text/javascript”>
var _paq = _paq || [];
_paq.push([“trackPageView”]);
_paq.push([“enableLinkTracking”]);
(function () {
var u=((“https:” == document.location.protocol) ? “https” : “http”) + “://www.tag4arm.com/tags4arm/”;
_paq.push([“setTrackerUrl”, u + “tag4arm.php”]);
_paq.push([“setSiteId”, “33”]);
var d = document, g = d.createElement(“script”), s = d.getElementsByTagName(“script”)[0]; g.type = “text/javascript”;
g.defer = true; g.async = true; g.src = u + “tag4arm.js”; s.parentNode.insertBefore(g, s);
})();
</script>
<?php
}
add_action(‘wp_head’, ‘tag4arm’);March 20, 2019 at 11:15 am #1080764I found a way to do it myself.. to be fair the lack of support on this really worries me.
- This reply was modified 5 years, 8 months ago by Gilesamc.
March 20, 2019 at 2:42 pm #1080836Hi,
Great, I’m glad you found a solution. We are here to help with the theme, the problem you were having is general WordPress development. Please try to distinguish between the two.
Best regards,
RikardMarch 20, 2019 at 2:54 pm #1080842To be fair this is kind of specific to your theme.. and your method didn’t work.. I reverted to generic wordpress methods to get this to work
March 22, 2019 at 8:34 pm #1082001Hi Gilesamc,
Glad you got it working for you! :)
If you need further assistance please let us know.
Best regards,
Victoria -
AuthorPosts
- You must be logged in to reply to this topic.