The Moz Q&A Forum

    • Forum
    • Questions
    • My Q&A
    • Users
    • Ask the Community

    Welcome to the Q&A Forum

    Browse the forum for helpful insights and fresh discussions about all things SEO.

    1. SEO and Digital Marketing Q&A Forum
    2. Categories
    3. Online Marketing Tools
    4. Automatically add an "onclick" to links?

    Automatically add an "onclick" to links?

    Online Marketing Tools
    8 3 2.0k
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as question
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • BryanPhelps-BigLeapWeb
      BryanPhelps-BigLeapWeb last edited by

      I need to add an "onclick" event across ~20 websites to improve my Google Analytics implementation.  I know I could do this manually but I"m wondering if there is a script or something that will do this automatically?

      I need to modify all the links to look like this:

      onclick="_gaq.push(['_link', 'http://www.website.com']); return false;">Website

      1 Reply Last reply Reply Quote 0
      • BlastAM
        BlastAM last edited by

        I'm guessing you want to add the onclick events on offsite links or the downloading of files since moving between internal pages in GA is already tracked.

        We recently wrote a blog post about this here: http://www.blastam.com/blog/index.php/2011/04/how-to-track-downloads-in-google-analytics/

        The automated tagging tool we use is Analytics Engine

        It works great and is easy to use.

        1 Reply Last reply Reply Quote 0
        • BryanPhelps-BigLeapWeb
          BryanPhelps-BigLeapWeb last edited by

          We want to track movement between company websites.  Not internal pages but different websites.

          We want to add the onclick even to push the user data across domains so we don't lose their history.

          1 Reply Last reply Reply Quote 0
          • BlastAM
            BlastAM last edited by

            Ok, to track movement between websites and see them all in one profile you will need to set up some cross domain tracking.

            We have another blog post that describes how to do this here: Google Analytics Cross Domain Tracking

            I think this is more what you are looking for.

            BryanPhelps-BigLeapWeb 2 Replies Last reply Reply Quote 0
            • BryanPhelps-BigLeapWeb
              BryanPhelps-BigLeapWeb @BlastAM last edited by

              That looks great but leads me back to my original question.  Is there an automated way to update all of our links between domaina.com and domainb.com to include the onclick gaq push?

              We have approximately 20 websites that are all interlinked in some way so it would take quite a bit of time to update every link on every site to include the onclicl.

              I'm wondering if there is some kind of tool/product out there that would update these links automatically to include the onclick or do we have to go into each site and manually update each link?

              adrianvender1 BlastAM 2 Replies Last reply Reply Quote 0
              • adrianvender1
                adrianvender1 @BryanPhelps-BigLeapWeb last edited by

                The script below can help you automate the cross-domain tagging using jQuery. A few notes:

                • Make sure that '_gaq.push(['_setAllowLinker', true])' is defined before the code below
                • Edit the 'domainList' array to define your set of domains
                • jQuery is required 🙂

                Let me know if you have any questions.

                1 Reply Last reply Reply Quote 3
                • BlastAM
                  BlastAM @BryanPhelps-BigLeapWeb last edited by

                  There are some automated scripts that you can try:

                  http://www.lunametrics.com/blog/2010/02/04/automatic-cross-domain-tracking/

                  http://www.analyticsmarket.com/freetools/link-tagger

                  You should always remember to test these 3rd party scripts out thoroughly after installing them to make sure they are tracking correctly.

                  1 Reply Last reply Reply Quote 2
                  • BryanPhelps-BigLeapWeb
                    BryanPhelps-BigLeapWeb @BlastAM last edited by

                    Thank you both for your help.  We'll look into these!

                    1 Reply Last reply Reply Quote 0
                    • 1 / 1
                    • First post
                      Last post
                    • Feedback on "Media Shower"
                      ahirai
                      ahirai
                      0
                      3
                      130

                    • Citation labs Link Prospector, Link target score good or bad?
                      KaneJamison
                      KaneJamison
                      0
                      3
                      199

                    • Is it considered "black hat" to embed my website name on a viral video?
                      EricaMcGillivray
                      EricaMcGillivray
                      0
                      9
                      162

                    • Google "Unnatural links" reconsideration request keeps failing
                      JaneCopland
                      JaneCopland
                      0
                      4
                      216

                    • How to Report Fraudulent "Clicker" to AdWords?
                      FedeEinhorn
                      FedeEinhorn
                      0
                      2
                      479

                    • An open discussion on the "ignored" social bookmarking sites
                      BrianCrouch
                      BrianCrouch
                      0
                      2
                      796

                    • Different "language" settings in Google Keyword tool does not change "search volume"
                      Justin_Vanning
                      Justin_Vanning
                      0
                      5
                      3.2k

                    • Best way to implement a "Latest Videos" list on partner sites
                      PhilNottingham
                      PhilNottingham
                      0
                      3
                      633

                    Get started with Moz Pro!

                    Unlock the power of advanced SEO tools and data-driven insights.

                    Start my free trial
                    Products
                    • Moz Pro
                    • Moz Local
                    • Moz API
                    • Moz Data
                    • STAT
                    • Product Updates
                    Moz Solutions
                    • SMB Solutions
                    • Agency Solutions
                    • Enterprise Solutions
                    • Digital Marketers
                    Free SEO Tools
                    • Domain Authority Checker
                    • Link Explorer
                    • Keyword Explorer
                    • Competitive Research
                    • Brand Authority Checker
                    • Local Citation Checker
                    • MozBar Extension
                    • MozCast
                    Resources
                    • Blog
                    • SEO Learning Center
                    • Help Hub
                    • Beginner's Guide to SEO
                    • How-to Guides
                    • Moz Academy
                    • API Docs
                    About Moz
                    • About
                    • Team
                    • Careers
                    • Contact
                    Why Moz
                    • Case Studies
                    • Testimonials
                    Get Involved
                    • Become an Affiliate
                    • MozCon
                    • Webinars
                    • Practical Marketer Series
                    • MozPod
                    Connect with us

                    Contact the Help team

                    Join our newsletter
                    Moz logo
                    © 2021 - 2026 SEOMoz, Inc., a Ziff Davis company. All rights reserved. Moz is a registered trademark of SEOMoz, Inc.
                    • Accessibility
                    • Terms of Use
                    • Privacy