Adding more code with my Google Analytics code when using your Google Analytics + plugin?

Hey folks,

I am using your Google Analytics + plugin. I have to now append my Google Analytics code with more tracking info per a service I want to you and below are their instructions:

Add the following to your GA tracking code directly before the </script>:

ga('set', 'dimension1', '<?php echo $keys['utm_content_id']; ?>');
ga('set', 'dimension2', '<?php echo $keys['utm_boost_id']; ?>');
ga('set', 'dimension3', '<?php echo $keys['utm_widget_id']; ?>');
ga('set', 'dimension4', '<?php echo $keys['utm_targeting']; ?>');

Your Google Analytics + plugin pulls our code from our GA id.

So, how can I do what they are asking since in your Google Analytics + settings the actual code is not showing and only pulling in dynamically upon page load from our GA ID. See here: http://screencast.com/t/xPeDom4n609z

Please let me know asap.

:slight_smile:

Greg

  • Nithin

    Hi Greg,

    Hope you are doing good today. :slight_smile:

    I'm afraid, there isn't any option to add the mentioned scripts through the Google Analytics plugin, it would require custom coding. I'm not sure whether the <?php echo $keys['utm_content_id']; ?> should be a variable, or not. You could try the following code in your themes functions.php file:

    function ga_add_advt() {
    	?>
    
    	<script>
    		ga('set', 'dimension1', '<?php echo $keys['utm_content_id']; ?>');
    		ga('set', 'dimension2', '<?php echo $keys['utm_boost_id']; ?>');
    		ga('set', 'dimension3', '<?php echo $keys['utm_widget_id']; ?>');
    		ga('set', 'dimension4', '<?php echo $keys['utm_targeting']; ?>');
    	</script>
    <?php>
    
    }
    
    add_action( 'wp_head', 'ga_add_advt' );

    If the above code doesn't work, you'll have to replace the variable <?php echo $keys['utm_content_id']; ?> with the values, ie in the above code replace utm_content_id, utm_boost_id etc with the a value, and then check whether it works.
    Eg:

    ga('set', 'dimension1', '12345');
    ga('set', 'dimension2', '4512');
    .....
    .....

    I hope this helps. Please let us know how that goes. Have a nice day. :slight_smile:

    Kind Regards,
    Nithin

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.