Hybrid View

  1. #1
    Sencha User
    Join Date
    Oct 2011
    Posts
    35
    Vote Rating
    0
    I3D is on a distinguished road

      0  

    Default onClick tracking event for internal slides?

    onClick tracking event for internal slides?


    Hi Guys

    I'm trying to integrate an onClick event that fires a tracking code just like a Google event tracker, I want to implement that for the buttons that use the function "Go To Scene" or any other function.

    So basically the onClick event format is:

    Code:
    onClick="Snakk.log('Address','Title', 'click');"
    Basically I want to be able to track how many people clicked or entered a specific slide.

    I'm pretty sure that I can do that by implementing a custom JS for the button to go to the other scene and then fire off the onClick event. Problem is that I haven't worked with Sencha for a year now and getting rusty with the syntax. Thanks

    Cheers

  2. #2
    Sencha - Architect Dev Team
    Join Date
    Apr 2012
    Posts
    264
    Vote Rating
    23
    miro.bojic will become famous soon enough miro.bojic will become famous soon enough

      1  

    Default


    Hi there,

    With the latest 1.3 release, we also improved the documentation of JS functions that are available when editing custom JS. You can find it here: http://docs.sencha.com/animator/1-3/...de/advanced_js

    To achieve what you are trying to do, you indeed need to set the click event to custom JS and then enter following:

    Code:
    //your tracking code
    Snakk.log('Address','Title','click');
    
    //go to next scene code
    controller.goToNextScene();
    Alternatively, you can also skip to another scene by using:

    Code:
    controller.startSceneById(scene_id);
    
    //or
    
    controller.startSceneByName(scene_name);
    The auto-substitution in the editor will list scene_id's / scene_names as you type.

    Finally, don't forget to include the definition of your tracking code function in the project header.

    Hope it helps, and good luck with your project.

  3. #3
    Sencha User
    Join Date
    Oct 2011
    Posts
    35
    Vote Rating
    0
    I3D is on a distinguished road

      0  

    Default


    Hi miro

    Actually that doesn't work, there is no way i can think off that can initiate an onClick event in sencha animate! Arne?

    Cheers

  4. #4
    Sencha User arnebech's Avatar
    Join Date
    Jun 2010
    Posts
    498
    Vote Rating
    10
    arnebech will become famous soon enough

      0  

    Default


    That should work

    Basically, you can set the click action in Animator for the object to custom JS and then you can call all the functions you want, like Miro described.

    If you are still having issues with it, could you describe what is not working?

  5. #5
    Sencha User
    Join Date
    Oct 2011
    Posts
    35
    Vote Rating
    0
    I3D is on a distinguished road

      0  

    Default


    Hi Arne

    When placing the click action before the controller.goToNextScene...etc the button refuses to execute.

    I've tried the following

    onClick("Snakk.log.....")
    Controller.onClick("Snakk.log......")
    Snakk.Log.......

    None of the above works. I've looked at the event tracking documentation for google analytics, the only way I could find was through an onClick function. There is another method that is suitable for Flash ActionScript only!

    Best

  6. #6
    Sencha User arnebech's Avatar
    Join Date
    Jun 2010
    Posts
    498
    Vote Rating
    10
    arnebech will become famous soon enough

      0  

    Default


    Sounds like your call to the tracking results in an error, hence the go to next scene is never reached.

    From the page you linked, here is an example of how to call google analytics from the code.

    Code:
    _gaq.push(['_trackEvent', 'Videos', 'Play', 'Baby\'s First Birthday']);
    
    //and then you could call the controller
    controller.goToNextScene();
    Note that in order to user libraries such as google analytics you need to load the library itself. Also, for better error messages you can open up the developer inspector in chrome and check the console for any error statements.