Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1203485
    Manny Costales
    Participant

    Hi, I’m trying to add the Active Campaign Tracking Code, but I don’t know where should I add it.
    Where is the best place to put a tracking code without adding a new plugin?

    #1203505
    Thai
    Moderator

    Hi There,

    Please add the following code under functions.php file locates in your child theme:

    add_action( 'wp_head', 'add_custom_script' );
    function add_custom_script(){
    	?>
    	<script type="text/javascript">
    	/* Your Scrip Will Go Here */
    	</script>	
    	<?php
    }

    Hope it helps 🙂

    #1203652
    Manny Costales
    Participant

    Thanks, but I have to put in the the footer (wp_footer), because in the header it broke my page, I lost my styles, fonts were crazy, image sizes…..
    why?

    #1203685
    Thai
    Moderator

    In this case, please try with this code instead:

    add_action( 'wp_footer', 'add_custom_script' );
    function add_custom_script(){
    	?>
    	<script type="text/javascript">
    	/* Your Scrip Will Go Here */
    	</script>	
    	<?php
    }

    Could you please provide us with your tracking code?

    Thanks.

    #1203973
    Manny Costales
    Participant

    that’s what I did,
    thanks

    #1204162
    Jade
    Moderator

    You’re welcome.

    #1339923
    adam h
    Participant

    Hi, sorry I am interested in this topic as well. However, I’m not exactly sure where to place the code or what the code should look like?

    Also, do I place it here:

    https://www.screencast.com/t/FQ7Tnl5M

    #1339925
    adam h
    Participant
    This reply has been marked as private.
    #1340163
    Christopher
    Moderator

    Hi there,

    Because this requires a template change, I’d advise that you setup a child theme. This allows you to make code changes that won’t be overwritten when an X update is released. After your child theme is setup, please review how we recommend making template changes in Customization Best Practices.

    Please connect to FTP and add following code in child theme’s functions.php file :

    function my_custom_footer_output() {
      ?>
      <!– Active Campaign Tracking Pixel Code –>
    <script>
    var trackcmp_email = ";
    var trackcmp = document.createElement("script");
    trackcmp.async = true;
    trackcmp.type = 'text/javascript';
    trackcmp.src = '//trackcmp.net/visit?actid=251631999&e='+encodeURIComponent(trackcmp_email)+'&r='+encodeURIComponent(document.referrer)+'&u='+encodeURIComponent(window.location.href);
    var trackcmp_s = document.getElementsByTagName("script");
    if (trackcmp_s.length) {
    trackcmp_s[0].parentNode.appendChild(trackcmp);
    } else {
    var trackcmp_h = document.getElementsByTagName("head");
    trackcmp_h.length && trackcmp_h[0].appendChild(trackcmp);
    }
    </script>
    <!– End Active Camapaign Pixel Code –>
      <?php
    }
    
    add_action( 'wp_footer', 'my_custom_footer_output', 99999 );

    Hope it helps.

    #1340759
    adam h
    Participant

    Christopher,

    Thanks for the tip. I must admit I am a novice website builder and this function.php has me a little stumped.

    I’ve taken your advice and uploaded the child theme, then I found my way through the editor section and pasted the code you provided under the additional functions section.

    https://www.screencast.com/t/5aNfm2XiTf

    I updated the file – Went to the page to check the status of the tracking pixel – However, it does not appear to be tracking

    https://www.screencast.com/t/LR0K12chs0VI

    Question 1 – Is this the correct place to paste the tracking pixel?

    Here is my tracking code

    <script type=”text/javascript”>
    var trackcmp_email = ”;
    var trackcmp = document.createElement(“script”);
    trackcmp.async = true;
    trackcmp.type = ‘text/javascript’;
    trackcmp.src = ‘//trackcmp.net/visit?actid=251631999&e=’+encodeURIComponent(trackcmp_email)+’&r=’+encodeURIComponent(document.referrer)+’&u=’+encodeURIComponent(window.location.href);
    var trackcmp_s = document.getElementsByTagName(“script”);
    if (trackcmp_s.length) {
    trackcmp_s[0].parentNode.appendChild(trackcmp);
    } else {
    var trackcmp_h = document.getElementsByTagName(“head”);
    trackcmp_h.length && trackcmp_h[0].appendChild(trackcmp);
    }
    </script>

    The site is currently in development – here is the url: http://029.071.myftpupload.com/

    Thank you

    Adam

    #1340780
    adam h
    Participant

    It looks like now I am consistently getting a parse error

    Parse error: syntax error, unexpected ‘<‘ in /home/content/p3pnexwpnas04_data01/52/3800452/html/wp-content/themes/x-child/functions.php on line 29

    #1340986
    Rue Nel
    Moderator

    Hello There,

    Would you mind providing us with login credentials so we can take a closer look and fixed this issue? To do this, you can make a post with the following info:

    – Link to your site
    – WordPress Admin username / password
    – FTP credentials

    Don’t forget to select Set as private reply. This ensures your information is only visible to our staff.

    Thank you.

  • <script> jQuery(function($){ $("#no-reply-1203485 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>