Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #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)

    #1078515

    Hey Gilesamc,

    Then there’s something wrong with your code, please check it carefully. If you need help then post it here.

    Best regards,
    Rikard

    #1078642

    got 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 Bing

    code 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&#8221; : “http://a.adroll.com&#8221;);
    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’);

    #1078643

    I 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

    #1078645

    it 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&#8221; : “http://a.adroll.com&#8221;);
    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’);

    #1079366

    Hi,

    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,
    Rikard

    #1079822

    so 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’);

    #1080764

    I 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, 9 months ago by Gilesamc.
    #1080836

    Hi,

    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,
    Rikard

    #1080842

    To 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

    #1082001

    Hi Gilesamc,

    Glad you got it working for you! :)

    If you need further assistance please let us know.

    Best regards,
    Victoria

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.