A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: [RESOLVED] Tracking with Google Analytics

  1. #1
    </hate> dtone314's Avatar
    Join Date
    Jun 2005
    Location
    CA
    Posts
    262

    resolved [RESOLVED] Tracking with Google Analytics

    I've searched the forum, but there were no definitive answers.

    I'm trying to use Google Analytics to track button clicks. I know there is an AS3 component, but I'm working on an AS2 project. Google gives examples on what the code should look like here, and I'm following those instructions to the dot, as far as I know, but I'm not getting any tracking results from the button in Analytics, and it's been 2 days since implementation. I must be overlooking something.

    My button has the following code:
    Code:
    on(press){
    	getURL("javascript:pageTracker._trackPageview('/SongDownloads');");
    }
    On my HTML page I set AllowScriptAccess to "always". The website I'm working on is here in case you want to check that my Analytics code is correctly in place.

    The HTML page itself is providing tracking results, just not the button clicks from Flash.

    I someone could PLEASE give me a hand here I would very much appreciate it. I've put 2 days into this and can't figure it out for the life of me. If you need more info, let me know.
    -dtøne-
    Flash CS4 | AS2
    Life is a journey, not a destination.

  2. #2
    AS3 Mod
    Join Date
    Sep 2007
    Location
    O-H-I-O
    Posts
    2,385
    Seems like it should work. How can you tell that it's not? Clicks won't show up immediately on analytics. Have you checked lately if you are seeing any results?

  3. #3
    </hate> dtone314's Avatar
    Join Date
    Jun 2005
    Location
    CA
    Posts
    262
    I'm looking under Content in Analytics, where it lists the pages being tracked. It says 100% of the traffic is going to "/", my single HTML page. I don't see any reference to "/SongDownloads" anywhere. Could I be looking in the wrong place?
    -dtøne-
    Flash CS4 | AS2
    Life is a journey, not a destination.

  4. #4
    AS3 Mod
    Join Date
    Sep 2007
    Location
    O-H-I-O
    Posts
    2,385
    Your code:
    PHP Code:
    <script type="text/javascript"
    var 
    gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." "http://www.");
    document.write(unescape("%3Cscript src='" gaJsHost "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
    </
    script
    <
    script type="text/javascript"
    try {
    var 
    pageTracker _gat._getTracker("UA-12520643-1");
    pageTracker._trackPageview();
    } catch(
    err) {}
    </
    script
    Needs to be in the proper place first. It should go down right before the </body> tag.

  5. #5
    </hate> dtone314's Avatar
    Join Date
    Jun 2005
    Location
    CA
    Posts
    262
    I had it there at first, but Google says that when there's other Javascript it can sometimes interfere with the Analytics code, and that the <head> is a more reliable place to put it. (reference)
    -dtøne-
    Flash CS4 | AS2
    Life is a journey, not a destination.

  6. #6
    </hate> dtone314's Avatar
    Join Date
    Jun 2005
    Location
    CA
    Posts
    262
    I missed your previous remark...

    I know the clicks have had enough time to "marinate" themselves into Analytics. I put this code in place 3 days ago now, and still no button stuff shows up. New page views take 1-3 hours to register, usually. Thanks for your help so far.
    -dtøne-
    Flash CS4 | AS2
    Life is a journey, not a destination.

  7. #7
    </hate> dtone314's Avatar
    Join Date
    Jun 2005
    Location
    CA
    Posts
    262
    Ok, I found the problem.

    I had 2 getURL calls, on after the other. One appeared to cancel the other out. I put a delay in between calling each, and now the data is showing up in Analytics. Wow.
    -dtøne-
    Flash CS4 | AS2
    Life is a journey, not a destination.

  8. #8

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center